使用jQuery或AJAX的“请等待”消息?

时间:2022-02-06 17:14:08

I am creating an enterprise web template to be used for development of all our web applications. Many of our existing applications take a while to load because of the amount of data and geographic distance of the data source, so users frequently click the same buttons and links twice.

我正在创建一个企业web模板,用于开发所有的web应用程序。由于数据源的数据量和地理距离,我们现有的许多应用程序需要一段时间才能加载,因此用户经常会单击相同的按钮和链接两次。

I plan to add a Please Wait message to come up when the page is posting back. I figured there are two obvious ways to do this:

我计划添加一个请等待消息出现时,页面正在张贴回来。我认为有两种明显的方法可以做到这一点:


1. AJAX Tools

1。AJAX工具

Using the AJAX UpdatePanel and progress loader, I can easily show a message on each postback with very little, if any, additional code.

使用AJAX UpdatePanel和进度加载程序,我可以很容易地在每个回发上显示一条消息,如果有的话,附加的代码很少。

My concern with the AJAX method is that, because this is very generic template, I would have to wrap the whole page in an update panel. From experience with the ASP.NET 3.5 AjaxToolKit, the update panel affects postbacks and JavaScript code in funky ways. Also, I think UpdatePanels are heavy and increase the amount of time needed to load the session or application.

我对AJAX方法的关注是,因为这是一个非常通用的模板,所以我必须在更新面板中包装整个页面。从经验和ASP。更新面板以奇怪的方式影响回发和JavaScript代码。另外,我认为UpdatePanels很重,会增加加载会话或应用程序所需的时间。

2. jQuery

2。jQuery

Using jQuery, I can bind a method that shows the message to each $(':submit').click() {} event. The page would automatically hide the message by reloading at the end of the post back.

使用jQuery,我可以将显示消息的方法绑定到每个$(':submit').click(){}事件。该页面将通过在回传结束时重新加载来自动隐藏消息。

I don't have major concerns with the jQuery method. It would require extra coding to work correctly with field validators. Not using the UpdatePanel also means the whole page is reloaded on every postback, which might not be the best method. It would also have to be delayed a few seconds before the 'Please Wait' message appears so that it doesn't appear for very small events that do not need such a message.

我不太关心jQuery方法。需要额外的代码才能正确地使用字段验证器。不使用UpdatePanel还意味着在每次回发时都重新加载整个页面,这可能不是最好的方法。它还必须在“请等待”消息出现之前延迟几秒钟,以便对于不需要这样消息的非常小的事件不会出现。


Which is the better way to show a Please Wait or Loading message? I am concerned with speed and reliability, but if there are other measures of success that you feel are noteworthy, feel free to say so.

哪一种更好的方式显示请等待或加载消息?我关注的是速度和可靠性,但如果你认为还有其他值得注意的成功衡量标准,请尽管说出来。

3 个解决方案

#1


5  

Definitely #2. Adding an UpdatePanel is a whole can of worms, and if you're not using them already on a given page, adds a lot of overhead.

# 2。添加UpdatePanel是一堆蠕虫,如果没有在给定的页面上使用它们,会增加很多开销。

The code involved in using jQuery to do this is trivial. There's a nice little plugin called blockui that can be used to render an effect and disable all controls on an area. It's not too hard to do this without the plugin either, but why reinvent?

使用jQuery进行此操作所需的代码非常简单。有一个很不错的插件叫做blockui,它可以用来渲染一个区域的效果并禁用所有控件。没有这个插件也不难做到,但是为什么要重新发明呢?

#2


3  

With the UpdatePanel, there is an UpdatePanelProgress control to display to the user a progress status message. With JQuery, you can display an element with the please wait message on button click, and attach a generic handler to the ajaxComplete, this callback fires when the AJAX request completes and then you can hide it.

使用UpdatePanel,有一个UpdatePanelProgress控件向用户显示一条进度消息。使用JQuery,您可以在单击按钮时显示一个带有请等待消息的元素,并将一个通用处理程序附加到ajaxComplete,这个回调在AJAX请求完成时触发,然后您可以隐藏它。

HTH.

HTH。

#3


1  

If you're using jquery, just use ajaxStart / ajaxStop.

如果使用jquery,只需使用ajaxStart / ajaxStop。

#1


5  

Definitely #2. Adding an UpdatePanel is a whole can of worms, and if you're not using them already on a given page, adds a lot of overhead.

# 2。添加UpdatePanel是一堆蠕虫,如果没有在给定的页面上使用它们,会增加很多开销。

The code involved in using jQuery to do this is trivial. There's a nice little plugin called blockui that can be used to render an effect and disable all controls on an area. It's not too hard to do this without the plugin either, but why reinvent?

使用jQuery进行此操作所需的代码非常简单。有一个很不错的插件叫做blockui,它可以用来渲染一个区域的效果并禁用所有控件。没有这个插件也不难做到,但是为什么要重新发明呢?

#2


3  

With the UpdatePanel, there is an UpdatePanelProgress control to display to the user a progress status message. With JQuery, you can display an element with the please wait message on button click, and attach a generic handler to the ajaxComplete, this callback fires when the AJAX request completes and then you can hide it.

使用UpdatePanel,有一个UpdatePanelProgress控件向用户显示一条进度消息。使用JQuery,您可以在单击按钮时显示一个带有请等待消息的元素,并将一个通用处理程序附加到ajaxComplete,这个回调在AJAX请求完成时触发,然后您可以隐藏它。

HTH.

HTH。

#3


1  

If you're using jquery, just use ajaxStart / ajaxStop.

如果使用jquery,只需使用ajaxStart / ajaxStop。