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?

+1  A: 

You could always run a server-side script that keeps running for a period of time. For example:

   sleep(10); //sleep for 10 seconds.
   print "This script has finished.";

oh that's interesting, I guess I could do the same in the main javascript call, just do a setTimeout for a long enough time to force the timeout condition.

+1  A: 

YUI Connection Manager allows you to introduce slowdown in your Javascript to test AJAX against latency.

+2  A: 

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?

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:


As long as you use a number sufficient so that your client-side code assumes the server has timed out, you should be good.

Jason Bunting

The ajax code is on the client side, server technology is I ended up simply calling the timeout method from the ajax call directly (and commenting out the part that I wanted to time out) you all gave great answers though so i gave you each an up vote :)