Reputation: 5183
I have the following ajax post:
$.ajax( {
type: "POST",
url: "http://192.168.7.9/api",
dataType: 'json',
data: { username: "john.doe", password: "123456", method: "search_samples" },
success: function ( data ) {
// Never get here
},
error: function ( XMLHttpRequest, textStatus, errorThrown ) {
// Always here: if async true, errorThrown has no message
// otherwise I se the NETWORK_ERR message
}
} );
It is returning with this error: NETWORK_ERR: XMLHttpRequest Exception 101.
I have read a bunch of SO posts on this error, most suggest that I set async to true. This DOES remove the error message- but it is still an error, and I never get valid data. It just seems to remove the error message which is not helpful.
In fiddler, on the same dev machine this works perfectly- is this a chrome issue? An origin issue? Is something wrong with my syntax?
Upvotes: 5
Views: 8960
Reputation: 8640
OK, it looks like you are running into issues with the same origin policy. The way you are doing it, you can't access AJAX data from a different server than the one that is hosting your application.
To do so, you would either have to move the http://192.168.7.9/api
functionality onto your server or use JSONP to transfer the data. Here is an example of how to do so.
Upvotes: 1