I have a problem which requires both javascript and php working together, but i don't know how to marry the two...
I have a server-generated page of a commercial product which displays item, description, price etc all generated from a sql database. The problem I am trying to overcome is obtaining the 'latest price'....
The price in the database can become 'old' so I want the page, when it is called to go and find the latest price from a remote server and then display that price (and if it's different from the price in the database, update the database). If the remote site takes, eg longer than 5 seconds to respond, the script will time out and display the price in the database.
If you can understand what I am trying to do there, maybe you can help me (pleeease!).
The thing is, I can do the above all in PHP without problems, but the thing is, while the script is running (esp. if the remote server is taking time to respond) the client browser is blank (even unconventially flushing the output buffer etc). What I want is for the page (with product, description etc) to display, with something saying 'obtaining latest price' while another script is called which fetches the latest price.
How can I do this?
My best solution is to use a javascript that starts when the page has loaded (don't know how to do that yet, since I'm not very good at javascript) to call a php script to go and fetch the info and then output the data received to the client.
How can I get javascript to call a php script?
Or is there a 'better' way.
I'm thinking it can be done, since sites like expedia.com have a page displaying saying 'please wait while we find your flights' or something like that, and then refresh the browser when data has been obtained (I would like javascript to just update the page, and not refresh it though...)
Million thanks to anyone who can help out, as I've been stuck on this for quite a while now