I am trying to get a cross-domain JSON data via $.ajax method
$.ajax({
type: "GET",
dataType: 'jsonp',
url: "http://nrb.org.np/exportForexJSON.php?YY=2016&MM=06",
crossDomain : true,
})
.done(function( data ) {
console.log("done");
console.log(data);
})
.fail( function(xhr, textStatus, errorThrown) {
console.log(xhr);
console.log(xhr.responseText);
// alert(xhr.responseText);
// alert(textStatus);
});
The JSON returned by the url is
{
"Conversion": {
"Currency": [{
"Date": "2016-06-23",
"BaseCurrency": "INR",
"TargetCurrency": "NPR",
"BaseValue": "100",
"TargetBuy": "160.00",
"TargetSell": "160.15"
}, {
"Date": "2016-06-23",
"BaseCurrency": "USD",
"TargetCurrency": "NPR",
"BaseValue": "1",
"TargetBuy": "107.76",
"TargetSell": "108.36"
}, {
"Date": "2016-06-23",
"BaseCurrency": "BHD",
"TargetCurrency": "NPR",
"BaseValue": "1",
"TargetBuy": "285.75",
"TargetSell": "N/A"
}]
}
}
I checked if the JSON is valid by using http://jsonlint.com/. The JSON is Okay. I get a console error.
Uncaught SyntaxError: Unexpected token :
The console is pointing to the error in the following screenshot
Aucun commentaire:
Enregistrer un commentaire