web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

JavaScript runtime error: Access is denied

(0) ShareShare
ReportReport
Posted on by 470

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.';
}
}
});

*This post is locked for comments

I have the same question (0)
  • Verified answer
    NathanBenelli Profile Picture
    on at

    Hi Muhammad,

    This may be expected since you are sending a request via JavaScript to a resource in a different domain than your CRM organization. This is called a Cross Domain request. I suggest you consider JSONP and CORS in order to workaround this issue. jQuery supports JSONP - api.jquery.com/jQuery.ajax - and can be a good start point to solving this problem.

    Also, you can take a look at this blog post: devproconnections.com/.../two-methods-handling-cross-domain-ajax-calls

  • Muhammad Salahuddin Profile Picture
    470 on at

    Thank you Nathan, your answer helped me to solve my problem.

  • Varun Singh Profile Picture
    943 on at

    Hi Muhammad,

    I am facing same problem, would you please help to tell what you did to solve this error. Would you tell me how you did ajax call also.

  • Muhammad Salahuddin Profile Picture
    470 on at

    Hi Varun,

    I was fetching data from Yahoo using AJAX request when faced the error. To work around, I created a custom CRM action.

  • Varun Singh Profile Picture
    943 on at

    Thanks Muhammad for replying. Actually I would like to know how you have solved Access is denied issue when you are trying to invoke web service.  Kindly help me I am totally stuck in my work.

  • Community Member Profile Picture
    on at

    Hi Muhammad 

    I am facing same issue. Can you please send my your code?

    Thank you.

    Hiren

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans