I am trying to complete a long-polling call to a subdomain. The problem is that I need to send the request to a subdomain (sub.example.com
) from example.com
.
I am using the following code:
$.ajax({
url: 'https://sub.example.com/sub',
cache: false,
headers: {
'If-None-Match': etag,
'If-Modified-Since': last_modified
},
success: function(data, status, headers) {
// success handler
},
error: function(headers, status, errorThrown) {
// error handler
}
});
Again, this piece of code is not placed on the same domain. It is placed on example.com
.
The problem here is that the browser is first sending a OPTIONS request, and if the server response is OK, it will continue with the GET request (which is what we want). However, I would like to avoid this first OPTIONS request by all means.
Is there anything I can change in the server setup that would allow this to happen?
Using datatype "jsonp" is not an option.