delay the showing of a ajax loading gif using jQuery -


What is the best way to delay the execution of AJAX-loader GIF when I show loader GIF and hiding a button Clicks, even if the time taken is a few hundred milliseconds, it gives the browser a kind of flicker. What do I want to say to show only GIF, if the AJAX request should take more than 1000 milliseconds to complete.

  & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ('# loader'). Hide (); $ ('# btnGetPeople') Click (function () {$ ('# loader'). Show (); $ .getJSON ("/ user / gatnum / 10", blank, function (data) {showPerson (data);});});}); Function Showers (Data) {Warning (Data); Hide $ ('# Loader'). } & Lt; / Script & gt;  

My loader is div ....

  & lt; Div id = "loader" & gt; & Lt; Img alt = "src =" / content / ajax-loader. Gif "/>  

What is the best technique to achieve this?

As you can see I had added a timeout which is delayed for appearing for 300 mms. If Ajax is fast, then the loader is actually shown The timeout is canceled before.

  & lt; script type = "text / javascript" & gt; Var scroller; $ (document) .ready (function () {$ (' # Loader '). Hide (); $ (' # btnGetPeople '). Click (function () {// only Take Show fear if the Ajax request lasts longer, then 300 MS ShowLoader = setTimeout ("$ ('# loader'). Show ()", 300); $ .getJSON ("/ user / gatenum / 10", blank, function (Data) {showPerson (data);});});}); function showers (data) {hide time} (warning); warning (data); hide $ ('# loader');} &  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -