5

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?

Nicros
  • 4,611
  • 12
  • 52
  • 98
  • Is this a cross domain request (i.e. is your main application not running at `http://192.168.7.9`)? – Steve Mar 27 '13 at 20:53
  • @Steve These machines are on the same subnet, but the 192.168.7.9 machine isn't in a domain at all... – Nicros Mar 27 '13 at 20:59

1 Answers1

1

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.

Community
  • 1
  • 1
Steve
  • 8,301
  • 6
  • 36
  • 52
  • So far no luck- I am trying to use jsonp as described, but I now get the following error: `jQuery19108882399478461593_1364424507799 was not called`. I think I read someplace the server itself has to support jsonp? Maybe that's whats going on? – Nicros Mar 27 '13 at 22:49