Ajax Multiple Requests and Periodical Updater

Hi,

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.

Thnks
NabilbahrAsked:
Who is Participating?
 
ChristoferDutzCommented:
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://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/
http://en.wikipedia.org/wiki/Push_technology#Long_polling (Just the long-polling part)
<script>
   addResult("blah","blah","blah","blah","blah","blah");
</script>

Open in new window

0
 
NabilbahrAuthor Commented:
Hi,

Can you suggest me a working example of this.

Thanks,
0
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.