需要测试一个ajax超时条件 [英] Need to test an ajax timeout condition
问题描述
正如标题所提到的,我有一个Ajax调用超时回调处理程序,我希望能够以测试条件,但没有什么是即将在脑海中立即就如何我可以强迫我的应用程序打的状态,有什么建议?
As the title mentions, I have a timeout callback handler on an ajax call, and I want to be able to test that condition but nothing is coming to mind immediately on ways I can force my application to hit that state, any suggestions?
推荐答案
首先,我认为你需要在你的问题更清楚 - 你使用的是什么技术,这是哪里的过程,是超时 - 服务器端或客户端?
First off, I think you need to be clearer in your question - what technology are you using and where is this process that is timing out - server-side or client-side?
如果你想拥有服务器端的code需要很长的时间,你使用的是.NET,把这行放到你调用服务器端的方法:
If you want to have the server-side code take a long time and you are using .NET, place this line in the method you call server-side:
System.Threading.Thread.Sleep(timeoutMilliseconds);
只要你使用了一些足以使您的客户端code假定服务器超时,你应该是不错的。
As long as you use a number sufficient so that your client-side code assumes the server has timed out, you should be good.
这篇关于需要测试一个ajax超时条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!