Sunday 5 February 2012

javascript is not working "access denied"


I have done bit of customisation on entity record by adding ribbon button and on pressing that button I call code from server, its works fine form that machine having url of "http://devserver/orgname/main.aspx however when I am trying to access my machine from a different machine with fully qualified name something like http://devserver.active.local/orgname/main.aspx my javascript is not working, and when I tried to close the page I was prompted with error screen and when I debuged javascript following is the line which was showing an error of "access denied" when trying to open connection,

var oXmlHttp = this.CreateXmlHttp();
oXmlHttp.open("POST", this.server + "/mscrmservices/2007/crmservice.asmx", (fUserCallback != null));

Here the this.server value is taken from Xrm.Page.context.getServerUrl() and is "devserver", and I am trying to access it from "devserver.active.local",

Reason:
It's a security thing to prevent people from using AJAX between websites and servers.

Basically, whenever you write a URL in AJAX, it has to be the same URL as the website you are running the script on. Even the www. has to be the same.


http://www.webdeveloper.com/forum/showthread.php?t=147342


Enable the option in the browser to "Access data sources across domain"

http://social.microsoft.com/Forums/en-US/04d357e2-847d-45af-bc34-f4f265fe1bbb/i-am-getting-access-denied-error-when-using-xmlhttprequest-in-javascript-to-fetch-data-from-database
 

No comments:

Post a Comment