Ajax Multiple Requests and Periodical Updater


I am trying to make an application using PHP (NuSOAP) and JavaScript. Its a Flight Booking Engine works same as Kayak.com search engine.

What i am trying to do is to make a queue of Availability Messages to be sent to Server via NuSOAP. There will be various availability responses from this message queue. Instead of showing responses of all messages at once, i want to show them as and when the response starts coming.  Like when the first response comes from server it updates a div on my availability page, few soconds later when second response comes it again updates flight div on availability page, it goes like untill request queue is empty.

The desired response from Availability Server is a Javascript Array of diffrent flight options, at present i am making this JS Array from a PHP page then calling a JS function to make the availability page from that JS function. In New version i am trying to get Javascript Array from Server and pass it onto PHP page for further processing and making availability page, when next response comes from Server, it again adds to the existing Array, sort it then make the availability page.

I am looking for suggestions, how i can aoomplish this.

Who is Participating?
In this case you have three options: Streaming connection using something like Flex's Socket-Connection, long polling or normal polling.

Well the easiest way would be to use a long polling using a long running HTTP request. In this you write the first part of your response flush it and wait for further responses to drop in. Every time a new response comes in you send the Data in a new <script> tag which contains the data, eventually rapped in a function-call and flushing every time a script tag is output.

http://en.wikipedia.org/wiki/Push_technology#Long_polling (Just the long-polling part)

Open in new window

NabilbahrAuthor Commented:

Can you suggest me a working example of this.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.