2

Maybe the title is bit off but I dont know how else to put it.

I have a script which allows to display Bing search results on keyup(jquery) The number of results can be set to a maximum of 50 results for each request. What I would like for my website is the ability to show only the first 10 results and by clicking a div each time other ten results would appear.

I can hide/show but that would mean that the 50 results would be loaded anyway which I want to avoid because of loading time.

Please take a look at this example to have a better understanding: Google Powered site search

This is exactly what Im looking for but I dont understand the coding..

This is the actual script Im using: JsFiddle

Any help would be appreciated.

Youss
  • 4,196
  • 12
  • 55
  • 109

1 Answers1

2

Why dont you just set the web.count=10 then when they click on the div, set the Web.Offset+=Web.Count+1 and load those results from the api?

Steve
  • 50,173
  • 4
  • 32
  • 41
  • Thanks, to tell you the truth I have no idea what 'offset' means or what it stands for, but I will look in to this and come back. – Youss Jan 27 '12 at 14:28
  • What it means is that number from which the next results will be. So if you have loaded 10 (web.count) then start from 11. Does this make sense? – Steve Jan 27 '12 at 14:29
  • That makes sense. But wouldn't the third request start at 21 and not 11 ?? – Youss Jan 27 '12 at 14:40
  • (I have to make it work and then come back and except your answer) – Youss Jan 27 '12 at 14:41
  • Thanks I have updated my answer, it should add the number loaded each time plus 1, if that makes sense – Steve Jan 27 '12 at 14:42
  • Im still working at it, I just dont hope that it will eventually give me the same 10 results each time...:) (I think your answer is definitely useful so I gave credit for now) – Youss Jan 27 '12 at 14:52
  • I understand now (I think) But wouldn't that require a different script for each div? – Youss Jan 27 '12 at 16:06
  • What you could do is keep track of each time you click on the div at the bottom and just requist the next 10, some thing like Web.Offset+=currentCount+Web.Count+1 – Steve Jan 27 '12 at 16:27
  • Thanks for your answer. I dont understand your last comment. Just Web.Offset=number seems to work. I will try this with divs. – Youss Jan 27 '12 at 19:30