Hi all experts.
I want the count the orders and their details out of the CRM, Via OData.
I have called an OData via simple JS inside HTML file.
I have created the OData URL via Rest Builder solution.
When I go to my URL, It works good and dsiplay me the output,
But when I call it via Ajax, It gives me this :
Failed to load xxxxxxxxxxxxx/.../SalesOrderSet$select=AccountId,Name,OpportunityId,SalesOrderId&$filter=StatusCode/Value%20eq%20100001%20and%20bmsd_OrderType/Value%20ne%20100000001: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 401.
also this :
Here is my JS Code :
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: "xxxxxxxx/.../SalesOrderSet$select=AccountId,Name,OpportunityId,SalesOrderId&$filter=StatusCode/Value%20eq%20100001%20and%20bmsd_OrderType/Value%20ne%20100000001",
beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
async: true,
success: function(data, textStatus, xhr) {
var results = data.d.results;
for (var i = 0; i < results.length; i++) {
var accountId = results[i].AccountId;
var name = results[i].Name;
var opportunityId = results[i].OpportunityId;
var salesOrderId = results[i].SalesOrderId;
}
},
error: function(xhr, textStatus, errorThrown) {
alert(textStatus + " " + errorThrown);
}
});
What I am doing wrong?
*This post is locked for comments
I have the same question (0)