Ajax calls speed up
I am currently learning AJAX and don't know much about it. I have to ask that is there any method or tool by which I can boost my AJAX calls any programming techniques or so. I am using live search like Google in my project, you can test the Search here :
Your Videos
It takes much time to show up the live search result (popup) although I have a small database of less than 100 records. I don't mean the results shown on the other page after search. 开发者_JAVA百科Please guide me !
Actually I have created ajax chat in my website and it was working slow, but then I got an idea that I call 0 or 1 from the server accordingly as 0 represents that data is same as the before one and 1 as data has been changed, and when the reply is 1 then I call for new data in next step. This technique works faster than calling the whole data every time.
I'm not sure that it's a good long term solution--and there are some philosophical issues. But as long as your database is small, you could load all the results and then output them on the page as inline JSON. Then your autocomplete script could parse through the JSON rather than making an ajax call. See http://www.phpied.com/json-data-island.
You could also have a server side language write the database as JSON to an external js file which updates only every couple of days.
Either one of those would mean no query's involved every time the autocomplete makes its ajax call.
There are lots of variations of pseudo-caching options like that, but I would find cookies inappropriate in this case.
It's already pretty fast, though.
精彩评论