This is my 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 this is the output of these console.dir lines: (Apparently I can't use images so I'll have to write it 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 the JSON object does get copied into the global variable in firefox, but in chrome I can't use the JSON as a global variable, if I try to print for example: accountStatus.total I get "undefined" as the value. What am I missing?
This is the full response: {"id_cuenta":"79","subtotal":"840","descuento":"0","total":"840","pagado":"0","adeudo":"840","fecha":"2014-09-10"}