I want to call AJAX on subdomain using jquery ajax() method:
I call it from http://domain.com/
$.ajax({
crossDomain: true,
url:'https://sub.domain.com/',
success: function(response) {
alert('ok');
},
error: function(resp) {
console.log(resp);
}
});
But it doesn’t work, calls error function with resp == {
status:0, readyState: 0, responseText : '', statusText: 'error'
}
Sub-domain ajax calls are also cross domain. This is even true if they point to the same place (like example.com and http://www.example.com). They (usually) point to the same place. We see them as the same thing. But to an Ajax call, it’s considered cross domain.
Please do a search on crossdomain ajax and you’ll find a lott to go on.