搜索后预加载屏幕?
我的主页中有一个航班搜索搜索框(类似于 http://www.travelpack.com/ )
当您在 http://www.travelpack.com/ 中搜索时,您会看到“我们正在搜索符合您要求的航班。 请稍等... “ 屏幕我没有,我想在我的网站上有一个类似的屏幕。
问题是,当我从主页单击搜索时 我正在使用 javascript 提交表单,
document.flight_search.action = 'php/flt-show-availability.php?&s=1&Sort=P';
document.flight_search.method = 'post';
document.flight_search.submit();
如何创建与旅行包中类似的加载屏幕。
i have a search box flight search in my home page (similar to http://www.travelpack.com/)
When you search in http://www.travelpack.com/ you will see a "We are searching for flights that meet your requirements.
Please wait...
" screen i didn't have it and i want a similar screen in my site.
the problem is that when i click search from my home page
i am using javascript to submit the form
document.flight_search.action = 'php/flt-show-availability.php?&s=1&Sort=P';
document.flight_search.method = 'post';
document.flight_search.submit();
how can i create a loading screen similar to that in the travel pack.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 jQuery 中,一个会显示屏幕,并在 ajax 调用(告诉应用程序生成结果)完成后转发,很像:
但在我看来,您给出的示例页面存在显示内容的问题:未在 url 中表示,因此,例如,您不能将 url 提供给其他人以让他查看结果。
所以,ajax 魔法 - 当然,但要小心。
in jQuery one would show the screen, and forward after the ajax call (which tells the appilcation to generate a result) is completed, much like that:
But in My Opinion, the example page you give has the Problem that the content shown does is not represented in the url, so, for example you can't give the url to somebody else to let him have a see at the results.
So, ajax magic - sure, but be careful.
您可以重定向到结果页面,将结果列表隐藏在包含加载消息的 div 后面。然后您通过 javascript(ajax 或类似的)接收结果并在后台构建列表。
当服务器完成搜索时,您的请求完成,您可以隐藏包含加载消息的 div(例如在回调函数中)。
You could redirect to the result page, hiding the list of results behind a div that contains the loading message. Then you receive the results via javascript (ajax or similar) and build up the list in background.
When the server is finished searching your request finishes and you can hide the div that contains the loading message (for example in the callback function).
好吧,您可以通过 ajax-request 发送表单并等待答复。
等待时显示加载程序。
如果请求成功,您可以做出不同的反应:
- 替换内容
- 转到生成的输出页面
well, you can send your form via ajax-request and wait for the answer.
while waiting display the loader.
if the request succeeds you can react differently:
- replace the content
- goto the generated output page