Access-Control-Allow-Origin issue in chrome and firefox
Hi,
I'm using the below snippet to call OData service, it's working in IE only.
Chrome / Firefox i'm getting the error "
XMLHttpRequest cannot load 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. "
- jQuery.support.cors = true;
var call = $.ajax({
url: 'http://machinename:8000/sap/opu/odata/sap/ZWS_PRD_SRV/PRODUCTS?$format=json',
type: "GET",
crossDomain: true, // enabled for cross domain
username: "user",
password: "password",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function (data, textStatus, jqXHR) {
ko.applyBindings(new PagedGridModel(data.d.results));
});
call.fail(function (jqXHR, textStatus, errorThrown) {
console.log("Call failed. Error: " + jqXHR.statusText);
});