Saturday 15 May 2010

jquery - AJAX and 200 OK messages: Are they required to complete a server side call? -


We are developing tracking systems that use the WordPress AJAX API, 3G calls on 3G AGX contracts and WordPress AJAX APIs This refreshes the page.

I see that sometimes my data entry efforts are failing at the back end and I agree (this is probably wrong) that this is happening because in our last AAGX call 200 is already clear, and breaks the connection, which means that the data is never stored.

Now I am under the assumption that as soon as a jQuery.ajax ({type: ' POST 'call has been issued, I can immediately close the page Even then my server side which I posted to receive, and

but my data test is showing that some data is not constantly being recorded. Do I have the right to think that this My last AJAX call should not be related to finishing (and before reloading the page) a pre-ajax call is cleared with 200 OK?

Thanks for any help!

Yes, yes If you send an AJAX request to the server, you can close the page, complete the server request (code execution).

But there is a point address, you do not know that your request has arrived at the server or not.

  jQuery.ajax ("htpp: //", {type: 'POST'});   

This is an asynchronous request, so it will execute the code in the background. Execution of this line of code does not mean that you have sent a request, after some time it works in the background.

  1. jQuery will parse your code, see what you want,
  2. This will create a xmlhttprequest object with the set option.
  3. And finally it will send the request to the server.

    So if you close the page immediately, before the third step, the request will not be sent.

    I recommend that you send a synchronize to the AJAX request and wait for any feedback on the fresh / closed page. Because Synchronous AJAX can temporarily lock the browser request, because the request is active.

      JQuery.ajax ({url: url, success: function (r) {}, async,  

    In this case, you must set an async fake to make it synchronous, : wrong});

No comments:

Post a Comment