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?

2
  • Is this a cross domain request (i.e. is your main application not running at http://192.168.7.9)? Commented Mar 27, 2013 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... Commented Mar 27, 2013 at 20:59

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.