简体   繁体   English

页面加载时更新模式对话框

[英]Updating modal dialog while page loads

I have a site written in Cold Fusion. 我有一个用Cold Fusion编写的网站。 One of the pages is my main search area, which has a form that submits to my results.cfm page. 其中一个页面是我的主要搜索区域,该区域具有提交给results.cfm页面的表单。 On results.cfm, I have several cfinclude template statements which call in each file that builds the page from what the user searched for. 在results.cfm上,我有几个cfinclude模板语句,它们在每个文件中调用,这些文件根据用户搜索的内容构建页面。

Depending on what the user searches for, the page sometimes takes a while to load. 根据用户搜索的内容,页面有时需要一段时间才能加载。 I'd like to show a modal dialog indicating the progress of the search. 我想显示一个指示搜索进度的模式对话框。 Each included template on the results page has as the first line 结果页面上包含的每个模板的第一行

<cfset session.progressStatus = "Loading [whatever it's loading]">

On my search form, I have it so that when the user submits the form, I'm showing the modal dialog. 在我的搜索表单上,我可以找到该表单,以便用户提交表单时显示模式对话框。 That all works fine, however after the dialog is shown, I'm using the code below in an attempt to make an ajax call to a script that simply gives me the value of the session.progressStatus variable. 一切正常,但是在显示对话框之后,我使用下面的代码来尝试对脚本进行ajax调用,该脚本只是为我提供了session.progressStatus变量的值。 I thought by doing things this way, as the page loads the dialog would continue to show and would have it's text updated to reflect the current operation. 我认为通过这种方式,在页面加载时,对话框将继续显示,并且将其文本更新为反映当前操作。 However, this is not the case. 然而,这种情况并非如此。 The dialog text does not change. 对话框文本不变。 What is really strange, is when I click search and the dialog is displayed, if I hit the escape key the dialog text starts to get updated accordingly, but the page stops loading. 真正奇怪的是,当我单击“搜索”并显示对话框时,如果我按了逃逸键,则对话框文本将开始相应地更新,但是页面会停止加载。

        progressTimer = setInterval(function(){
        $.get("ajax/ajax_get_progress.cfm", { type:"progress" }, function(result){
            result = result.replace(/^\s+|\s+$/g,'');
            console.log('result is: ' + result);
            progressMessage = (result=="") ? "Performing Search" : result;
            $progressIndicatorMessage.html(progressMessageStart + progressMessage + progressMessageEnd);
        });
    }, 1000);

Anyone have any idea as to WHY?? 有人对为什么有任何想法吗? I'm very confused. 我很困惑

In response to, " better ways to amuse the user while the page is processing....suggestions?", ..., 作为响应,“在页面处理过程中有更好的方法来娱乐用户……建议?”,...,

Here are some references for a progress bar. 以下是进度条的一些参考。

Another option is to instantly display an image file in a div with and cfflush, then when the page has processed, replace the contents of the div. 另一个选择是使用和cfflush在div中立即显示图像文件,然后在处理完页面后,替换div的内容。 This will entail the use of cfsavecontent and javascript. 这将需要使用cfsavecontent和javascript。 Here are some links . 这里有一些链接

Another option, display the image as described above. 另一个选项,如上所述显示图像。 Use cfsavecontent, but with a session variable. 使用cfsavecontent,但带有会话变量。 Then use cflocation to go to another page where you output the session variable. 然后使用cflocation转到另一个页面,在该页面上输出会话变量。 This is probably the simplest option, plus, it will probably disregard pressing the escape key. 这可能是最简单的选项,另外,它可能会忽略按Escape键。 You'll have to verify that. 您必须进行验证。

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

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