$.post("http://openexchangerates.org/", parameters,
function (data) {
var currencyData = eval('( '+data+')');
currency = currencyData["currency"];
}
);
// I want to access currency here. But I am unable to access it.
$.post(http://openexchangerates.org/, parameters, function (data) { var currencyData = eval(‘( ‘+data+’)’); currency = currencyData[currency]; }
Share
try declaring the currency variable outside the ajax function.
you can set it a default value at first to prevent ambiguity if it returns ‘undefined’ (for debug purposes)