lundi 2 septembre 2019

How to parse data from random.org in JS?

I have a random.org system that is connected to the Laravel controller:

$random = new RandomOrgClassicClient();
$arrRandomInt = $random->generateIntegers(1, 1, $lastBet->to, false, 10, true);
$winTicket = $arrRandomInt[0];
$this->game->signature = $random->last_response['result']['signature'];
$this->game->random = json_encode($random->last_response['result']['random']);
$this->game->number = $winTicket;

How can I parse this data in the JS? I tried doing this:

<form action='https://api.random.org/verify' method='post' target=\"_blank\">
<input type='hidden' name='format' value='json' />
<input type='hidden' name='random' value='" + JSON.stringify(data.game.random) + "' />
<input type='hidden' name='signature' value='" + data.game.signature + "' />
<input class=\"check-on-random-org-btn\" type='submit' value='Check on Random.org' /></form>

Also i try change data.game.random to data.random and data.game.signature to data.signature, but every time I get a signature error on the site random.org.

How i can fix it?




Aucun commentaire:

Enregistrer un commentaire