I have a script which allows to display Bing search results: JsFiddle
I want to paginate this script which means setting a div which on click will do a second request only this time showing the next amount of results. I know this has to be changed:
var WebCount = "Web.Count=12";
var WebOffset = "Web.Offset=0";
The second reqeust would look like:
var WebCount = "Web.Count=12";
var WebOffset = "Web.Offset=1";
And so on.
I also know that the function doSearch should be renamed for the second request (ea doSearch2)
So my question is what else should I change to perform a second request?
I’m trying not to copy the same script and changing all the (function) names.
You don’t need to duplicate the search function to show the second page. Just update the value of the variable
WebOffsetand rundoSearch. Or add an Offset parameter to the function:Look here for an example: http://jsfiddle.net/Tz6wC/
(Note: I removed some stuff from your code that is not necessary for this example)