Reputation: 2331
Hi odd question to ask but am trying to simulate a user issue upon our site.
Is it possible to delay a reponse from an ajax request.
What I am looking to simulate is what happens to our page when no reponse comes back from a valid url.
appreiciate any pointers
Thanks in advance
Upvotes: 3
Views: 1418
Reputation: 5707
You COULD use a sleep() function in your server code to make the request take longer, but if you are trying to test this against a production server, I assume you want to introduce the delay (or nonresponse) on the client side. I would suggest a network throttler to simulate slow network response times. I personally use the cross-platform Charles proxy (no affiliation, but I'm a big fan) to handle this, but you can search Google for other alternatives.
Upvotes: 0
Reputation: 21957
You can make it on server side. For example in PHP script called by AJAX you can make sleep(5)
. I hope that you have familiar function on your server-side language.
Upvotes: 0
Reputation: 1240
If the ajax request goes to the server, why not let the server sleep()
or equivalent?
Upvotes: 0
Reputation: 49919
Use this in your PHP: http://php.net/manual/en/function.sleep.php
sleep(60);
If you got a timeout set at 30 seconds, the timeout will be called.
Upvotes: 2