PDA

View Full Version : cors issue



sandy52
15 Oct 2014, 10:30 PM
Hi everyone,
I am stuck in calling data from other domain using service bus, when I try to send get method ajax send first option request which reject by browser(or may be service bus dont know). Can I avoid option request from ajax call, I tried useDefaultXhrHeader but not solve my problem. Here is my code for ajax call :


Ext.Ajax.useDefaultXhrHeader = false;
Ext.Ajax.cors = true;
Ext.Ajax.request({
url: serviceBusUrl + 'Employee', //?token=' + Base64.encode(decodedURI),
headers: headers,
callback: function (a, s, d) {
debugger;


},

});

50709
Please help me out.

Thanks,
Sandy

skirtle
17 Oct 2014, 12:13 AM
Custom headers activate the pre-flight OPTIONS check.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

However, given the error message in the screenshot I wonder whether the server has CORS enabled at all.

sandy52
17 Oct 2014, 12:51 AM
Hi skirtle,
Yup cors enabled at server side, when i try to get data from this url using token into a ResApi Client it respond properly but ajax send first option request which not came to server.

sandy52
21 Oct 2014, 1:35 AM
any suggestion guy's for this issue :((

skirtle
21 Oct 2014, 5:01 AM
What more do you need to know?

As I mentioned previously the OPTIONS request is caused by custom headers. The page I referenced gives full details of what causes the OPTIONS request.

Either you need your server to support CORS pre-flighting or you need to drop the headers.