I'm facing below error while calling yahoo api (web api) to get currency exchange rate. I'm getting XML (Response) via ajax call:
Error:
Exception was thrown at line 1, column 80004 in jessy.crm.dynamics.com/.../jquery-2.1.1.min.js
0x80070005 - JavaScript runtime error: Access is denied.
If there is a handler for this exception, the program may be safely continued.
I have ajax call in a function executed on homepage ribbon button click. Below is the ajax call
$.ajax({
type: "POST",
url: "query.yahooapis.com/.../yql * from yahoo.finance.xchange where pair in ('EURGBP', 'USDGBP')&env=store://datatables.org/alltableswithkeys",
dataType: "xml",
processData: false,
beforeSend: function () {
},
success: function (data) {
if (data != null && data != "undefined") {
var xml = data,
$rate = $(xml).find("rate");
var totalRates = $rate; //if rate != null
var objResponse = new Object();
if (totalRates != null && totalRates.length > 0) {
var rates = totalRates.length;
var euro = null;
var usd = null;
for (var i = 0; i < totalRates.length; i++) {
var id = totalRates[i].id;
if (id === "EURGBP") {
euro = totalRates[i];
}
else if (id === "USDGBP") {
usd = totalRates[i];
}
}
if (euro != null && euro != "undefined") {
objResponse.EuroRate = $(euro).find("Rate").text();
objResponse.Date = $(euro).find("Date").text();
}
if (usd != null && usd != "undefined") {
objResponse.UsdRate = $(usd).find("Rate").text();
}
}
}
return objResponse;
},
error: function (jqXHR, exception) {
if (jqXHR.status === 0) {
errormsg = 'Not connect.\n Verify Network.';;
} else if (jqXHR.status == 404) {
errormsg = 'Requested page not found. [404]';;
} else if (jqXHR.status == 500) {
errormsg = 'Internal Server Error [500].';;
} else if (exception === 'parsererror') {
errormsg = 'Requested JSON parse failed.';;
} else if (exception === 'timeout') {
errormsg = 'Time out error.';;
} else if (exception === 'abort') {
errormsg = 'Ajax request aborted.';;
} else {
errormsg = 'Uncaught Error.';
}
}
});