It looks like what you are doing there is called long polling, check this out:
http://en.wikipedia.org/wiki/Comet_(programming) -- Josh -----Original Message----- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of hotdog...@gmail.com Sent: Friday, December 12, 2008 3:18 PM To: jQuery (English) Subject: [jQuery] Re: Problems with more than one AJAX request at a time On Dec 12, 1:02 pm, "Josh Nathanson" <joshnathan...@gmail.com> wrote: > Yes, you should be able to fire the other requests. Maybe you could post a > little code. Ah, thank you for your quick response! Here's the relevant part of my code: http://paste2.org/p/114906 This is in the <head /> section of my page. What I'm trying to do here is implement a message system where people can send messages to each other. Right now, it's at a proof-of-concept stage. I'll give you the rundown of my code: Firstly, jQuery's AJAX setup is called so the requests never cache in the browser. Then, all the current messages are gotten and added to the document with the call to $.getJSON("message"). Then, I defined a a waitformessages() function. In here, an AJAX request is sent to the server (http://hostname/wait). This request is special because the server doesn't send a response back until a new message appears and there's something to send. Then, the cycle starts itself over with another call to waitformessages(). Finally, I have a form and its submit handler is set up to post a new message using AJAX to http://hostname/new?message=yadda . Here's what's supposed to happen: The user loads the page. All the messages are displayed and waitformessages() has a persistent connection to the server just waiting for somebody to say something. They type something in the form, the request gets sent, and immediately the callback in waitformessages() will fire, showing their message on the screen. Problem is, according to firebug, the AJAX call to submit the new message never gets sent because the call in waitformessages() hasn't finished yet. D'oh. If you'd like, I can post the server source code here too. It's written in CherryPy. Thanks a bunch and Merry Christmas! -Mike