简体   繁体   English

搜索后预加载屏幕?

[英]pre-load screen after searching?

i have a search box flight search in my home page (similar to http://www.travelpack.com/ ) 我的主页上有一个搜索框航班搜索(类似于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. 当您在http://www.travelpack.com/中搜索时,您会看到“我们正在搜索符合您要求的航班。请稍候...”屏幕,我没有该屏幕,我想在我的屏幕中显示一个类似的屏幕现场。

the problem is that when i click search from my home page i am using javascript to submit the form 问题是,当我单击主页上的搜索时,我正在使用javascript提交表单

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. 如何创建类似于旅行包中的加载屏幕。

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: 在jQuery中,将显示屏幕,并在ajax调用(告诉应用程序生成结果)完成后继续前进,就像这样:

$('.search').click(function(event){
  event.preventDefault();
  $('#loadAnimationWrapper').show();

  $.ajax({
    cache: false,
    async: false,
    type: 'GET',
    url: '/your/callback/url',
    success: function(data) {
      // your forwarding code
    }
 });
});

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. 但是在“我的观点”中,您提供的示例页面存在以下问题:所显示的内容未在URL中表示,因此,例如,您无法将URL提供给其他人以使他看到结果。

So, ajax magic - sure, but be careful. 所以,阿贾克斯魔术-当然,但是要小心。

You could redirect to the result page, hiding the list of results behind a div that contains the loading message. 您可以重定向到结果页面,将结果列表隐藏在包含加载消息的div后面。 Then you receive the results via javascript (ajax or similar) and build up the list in background. 然后,您将通过javascript(ajax或类似语言)接收结果,并在后台建立列表。

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). 服务器完成搜索后,您的请求完成,您可以隐藏包含加载消息的div(例如,在回调函数中)。

well, you can send your form via ajax-request and wait for the answer. 好了,您可以通过ajax-request发送表单并等待答案。 while waiting display the loader. 等待显示加载程序时。

if the request succeeds you can react differently: - replace the content - goto the generated output page 如果请求成功,您可以做出不同的反应:-替换内容-转到生成的输出页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM