3

我有一个 .NET 应用程序,它通过 AJAX 调用访问位于处理程序上的方法。通常,当用户单击某些按钮时,会触发此 AJAX 调用。我的问题发生在用户多次单击按钮时。它弄乱了我所有对象的状态。

你如何照顾它?我知道我可以阻止用户点击,直到第一次通话结束,但我想找到一个解决方案来处理服务器端的这个问题。任何想法?

谢谢!

4

3 回答 3

1

I believe that this is best achieved using client code. If you are using jQuery then one() may be an elegant solution. Alternatively you could set a variable to true when starting a request and set it to false when finished. Then prevent all further requests while the variable is set to true.

Doing it server side won't work. The server may have finished processing, but the message hasn't arrived to the client yet. The client then makes a new request. The server reacts to it as it is a new one. Havoc may occur in cases like this.

于 2010-01-18T11:10:14.607 回答
1

在 onclick 方法中,移除按钮的 onclick 处理程序,然后在后台使用 setTimer 运行 ajax 调用,并返回 true...

当 ajax 完成时,您可以选择重新附加 onclick 处理程序。

于 2010-01-18T11:05:14.730 回答
0

使用 jquery blockUI 插件。当用户第一次点击按钮然后锁定用户页面。完成用户任务后解锁页面。

参考http://malsup.com/jquery/block/#

于 2010-01-18T13:05:29.957 回答