javascript - What triggers my Preloader gif to show on Page, while Page is loading? -


Hi, I am trying to display a .gif while one page is loading new content I am ajax, javascript, I understand jquery, but how do I understand how to do it.

Here is Div with GIF ...

  & lt; Div id = "loading" & gt; & Lt; Div style = "display: none;" Id = "overlay" & gt; & Lt; / Div & gt; & Lt; Div id = "popup" style = "display: none;" & Gt; & Lt; Img alt = "loading value" src = "/ images / loading 2. gif" /> & Lt; Div class = "dialogtext" & gt; In loading rates available, it can take a moment. & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

Here's some javascript I've written that some of this works:

I do not know how to trigger it, and would appreciate the help or reference < / P>

Do you want to show loader GIF when an AJAX request is pending?

You can use the most basic event handler for

  // Show / hide the loading icon on a Ajax event $ (document). On ({ajaxStart: function () {$ ('# myLoadingDiv') .show ();}, ajaxStop: function () {$ ('# myLoadingDiv'). Hide ();}});   

And just to start with your parents div with display: any (or just show / hide to meet your specific needs Compromise the call)

There are several variations of this if you want to add the loader to just one AJAX call (assuming you're using multiple AJAX calls and you only have one loader ), You can do something like this:

  var myAjaxRequest = $ .ajax ({// your A Ax stuff first here: function () {$ ('# myLoadingDiv'). Show ();}} $. When (myAjaxRequest) .done (function () {$ ('# myLoadingDiv' ') .hide (); }   

away from the top of my head, I think you should also be able to put {$ ('# myLoadingDiv').);} Hide the AJAX call immediately before and when it is requested.

If there are multiple requests, you will want to make some difference in the effect of the following code:

  Var myAjaxRequests = [] myAjaxRequests.push ($ .ajax ({// your edge Ax stuff first here: function () {$ ('# MyLoadingDiv'). Show ();}} ); $ when. Apely ($, MyExXinstance). Don (function () {$ ('# my loading dev'). Hide ();}   

The purpose of () array in different arguments If you are using some Ajax requests, you probably do not need an array, you can pass them all, but this is good for large numbers.

I've just hoped to have this code popped up in the browser, but it can be small errors that I use to complete (I think) the exact same functionality you are looking for.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -