Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can grab an animated GIF of a spinning circle from <a href="http://www.ajaxload.info/" rel="noreferrer">Ajaxload</a> - stick that somewhere in your website file heirarchy. Then you just need to add an HTML element with the correct code, and remove it when you're done. This is fairly simple:</p> <pre><code>function showLoadingImage() { $('#yourParentElement').append('&lt;div id="loading-image"&gt;&lt;img src="path/to/loading.gif" alt="Loading..." /&gt;&lt;/div&gt;'); } function hideLoadingImage() { $('#loading-image').remove(); } </code></pre> <p>You then just need to use these methods in your AJAX call:</p> <pre><code>$.load( 'http://example.com/myurl', { 'random': 'data': 1: 2, 'dwarfs': 7}, function (responseText, textStatus, XMLHttpRequest) { hideLoadingImage(); } ); // this will be run immediately after the AJAX call has been made, // not when it completes. showLoadingImage(); </code></pre> <p>This has a few caveats: first of all, if you have two or more places the loading image can be shown, you're going to need to kep track of how many calls are running at once somehow, and only hide when they're all done. This can be done using a simple counter, which should work for almost all cases.</p> <p>Secondly, this will only hide the loading image on a successful AJAX call. To handle the error states, you'll need to look into <a href="http://docs.jquery.com/Ajax/jQuery.ajax" rel="noreferrer"><code>$.ajax</code></a>, which is more complex than <code>$.load</code>, <code>$.get</code> and the like, but a lot more flexible too.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload