

Why does not my OData jQuery Dynamic CRM On-Line query work?
source link: https://www.codesd.com/item/why-does-not-my-odata-jquery-dynamic-crm-on-line-query-work.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Why does not my OData jQuery Dynamic CRM On-Line query work?
I have a web page that needs to obtain information from Dynamics CRM2011 on-line using jQuery. As a test, I've just tried to retrieve all of the accounts from a test system. I've used some code that I've tested within the CRM product, and it works.
When I try to run the same jQuery code in a separate web page that is not on the CRM domain it doesn't work (no transport) so I added the $.support.cors = true line to allow cross-site scripting. Now when it runs it pops up a dialog box asking for credentials. However, when I enter my credentials for CRM on-line, it doesn't accept them. After three attempts I get the error, "unauthorized".
Can anyone help?
Here's the code:
$(document).ready(function()
{
var request = "https://myorganisation.crm4.dynamics.com/XRMServices/2011/OrganizationData.svc/AccountSet";
$.support.cors = true;
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: request,
async: false,
beforeSend:
function (XMLHttpRequest)
{
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success:
function (data, textStatus, XmlHttpRequest)
{
var result = data.d.results[0];
alert('Success');
alert(result);
alert(result.Name);
},
error:
function (XmlHttpRequest, textStatus, errorThrown)
{
alert(textStatus);
alert(errorThrown);
}
});
});
The oData endpoint doesn't support cross site requests. It is designed to only support authentication from within the CRM application using either Silverlight or JavaScript Web Resources.
Take a look at this MSDN article for more info.
Recommend
-
6
Ajax with jquery does not work advertisements In view page: <script languge="javascript" type="text/javascr...
-
9
JQuery Does Not Work on Hyperlink advertisements I wrote a php script index.php as given below. This script will create some hype...
-
7
Technical Articles
-
8
jQuery $ (this) .position (). top does not work in Chrome advertisements I was wondering if there would be any reason this piece of code will...
-
10
JQuery mouseover feature does not work properly advertisements On hover functionality is not moving perfect. Th...
-
8
Jquery .not () to close the menu (or modal) does not work advertisements I have a menu that toggles open clicki...
-
8
The DISTINCT keyword does not work in the mysql query advertisements I have ran into a problem that my mysql query is not w...
-
3
Posted 2 years agoUp...
-
4
Nitin Sharma March 26, 2023 5 minute read ...
-
5
Introduction In the previous blog, we have discussed about the URI calls which do not require any custom implementation. In this blog, we will go through the URI’s which do require custom implementation. Steps We can divid...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK