Hi, right I'll try put this across quickly but basically at the moment I have AJAX posting to a separate PHP page and then getting the response which is echoed on that page which is then used on the original page to display. This works fine and is all good, but the type of site I am creating requires the script to grab the information every second, and at the moment all I'm grabbing is one piece of information. What I need is to grab about 4 different pieces of information from the same mysql request. So at the moment it can make 1 mysql request a second and is able to get all the information in one go, but if I echo it, when it gets into the other page it will be in javascript and I can't find a way to split the data up and use it in different parts of the page.

Obviously I could use 4 different requests to the PHP page for the different information but this will put strain on the database which I suspect doesn't need to be the case.

So if anyone can help, I either need Javascript/AJAX to split the information up (can use PHP to put it into a string separated by + signs or whatever before being sent to javascript) OR another way to get the data all in one to be used in different parts of the page every second.

Recommended Answers

All 2 Replies

Not sure what you are returning, but maybe a JSON response can do the trick.

Apart from that: every second a refresh ? Is the data different each time, or are you just stress testing your server ?

I'm returning 3 things at the moment. A monetary amount, a time (ex: 32s) and a username of a user. Each one could be different, basically it's a penny auction script I'm coding. So each second it checks how much time is left, who the top bidder is and what the price is. The reason I can't use client side for the time is that everytime someone places a bid, the auction goes up by 20 seconds and the price goes up by a penny (look up penny auctions if you don't know how they work :) )

I'll look into using JSON though, thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.