javascript - Assigning returned JSON to global variable in chrome -


this code:

var accountstatus;  function getaccountstatus() {     $.ajax({         type: "post",         url: "/getaccountstatusjson.php",         async: false,         data: "id_alumno=1",         datatype: "json",         success: function (account)         {             console.dir(account);             accountstatus= account;             console.dir(accountstatus);         }     }); } 

and output of these console.dir lines: (apparently can't use images i'll have write out.)


chrome:

object

adeudo: "840"

descuento: "0"

total: "840"

[object object]


firefox:

adeudo: "840"

descuento: "0"

total: "840"

adeudo: "840"

descuento: "0"

total: "840"


so json object copied global variable in firefox, in chrome can't use json global variable, if try print example: accountstatus.total "undefined" value. missing?

this full response: {"id_cuenta":"79","subtotal":"840","descuento":"0","total":"840","pagado":"0","adeudo":"840","fecha":"2014-09-10"}

it doesn't accountstatus being used. change status.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -