两个脚本做同样的事情
我有一个允许显示 Bing 搜索结果的脚本: JsFiddle
我想对这个脚本进行分页,这意味着设置单击后将执行第二次请求的 div,仅这次显示下一批结果。我知道这必须改变:
var WebCount = "Web.Count=12";
var WebOffset = "Web.Offset=0";
第二个请求看起来像:
var WebCount = "Web.Count=12";
var WebOffset = "Web.Offset=1";
等等。
我还知道应该为第二个请求重命名函数 doSearch (ea doSearch2)
所以我的问题是我还应该更改什么来执行第二个请求? 我试图不复制相同的脚本并更改所有(函数)名称。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无需重复搜索功能即可显示第二页。只需更新变量
WebOffset
的值并运行doSearch
即可。或者向函数添加 Offset 参数:在此处查看示例:http://jsfiddle.net/Tz6wC/
(注意:我从您的代码中删除了一些本示例不需要的内容)
You don't need to duplicate the search function to show the second page. Just update the value of the variable
WebOffset
and 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)