Search code examples
javascriptjqueryajaxresponse

how to increase ajax/jquery loading time


I just shows an image "loading.gif" while my page is sending ajax request. But i get the response very fast so that the loading image is not visible, it lasts only for less than a second. I just want to control and increase the response time. in order to visible the loading image at least for 2 seconds. Is there any way?


Solution

  • You can use jquery setTimeout().

    setTimeout(function() { /* Your Code */ }, 2000);
    

    (This will wait two seconds before doing the ajax request.)

    Try in Fiddle