Solved

Ajax Multiple Requests and Periodical Updater

Posted on 2009-05-07
2
390 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:Nabilbahr
2 Comments
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 500 total points
ID: 24334054
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
 

Author Comment

by:Nabilbahr
ID: 24480840
Hi,

Can you suggest me a working example of this.

Thanks,
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now