I am doing a cross-domain request from site1.com to site2.com (both maintained by me)
This is the jquery code on site1.com :
$.ajax({
type: POST ,
url: http://site2.com/test/carrousel.cfm ,
cache: false,
async: true,
crossDomain: true,
dataType: "jsonp",
success: function (data, status) {
alert(data);}
},
error: function (xhr, textStatus, errorThrown) {
alert( error );
}
});
I can see the request coming in with status 200 in the debugger. The response body also contains the string that I m sending from the server. That string is: "okay"
Strange enough, the error handler is always fired and I can t access the data. I m sending the Access-Control-Allow-Headers and Access-Control-Allow-Origin headers via the server too (I came across some posts asking to do this)
I also get a script error saying OKAY is undefined. OKAY is the string I get as a reply from the server. How come this is happening? And How can I get this cross domain request to succeed?
I m using JQUERY 1.10.2 & IE 10
As you can see I m also using jsonp & the right parameters as defined in the jquery documentation to perform cross domain requests