I need to retreive data from a form using a javascript call. From there I need to send the data to a php script that inserts it in 开发者_开发问答to a database. I have an AJAX call that does this...but I know that the AJAX call monitors for a response from there Server. This will work but I'm looking for a more efficient way to do it, i.e. a way to do it with out "monitoring" the server for a response.
You may want to look at the fire-and-forget pattern for some ideas as to how to do this, and lessons learned.
http://ajaxian.com/archives/ajaxian-fire-and-forget-pattern
There are some lessons there that didn't seem obvious to me, such as this nugget:
We noticed that if we fired off a lot of XHR requests, we would max at 5, and the others died.
Ajax gets the response from the server it doesn't need to do anything with it. Asynchronous Ajax calls won't block the page that is calling it either.
The server doesn't/can't wait for the response to be received before it processes anything (so I don't think you have a problem to start with).
The server will process the request as soon as it is received. The response being sent back doesn't affect how soon the server can start processing.
精彩评论