2
Contributors
4
Replies
17
Views
3 Years
Discussion Span
Last Post by centenond
1

Have you tried a conditional statement?

if (condition is true)
{
    // load div;
}
0

Jorge I always do it like this in php. But for example if i have a div that takes like 10 seconds to load and i write an if statement your saying that it will be faster if is false? or it will take 10 seconds anyways? .. dont know if u understand i speak mainly spanish.. Also how to do a spinner (or a "Loading...") and dont show the div until all div content is loaded
Thanks

Have you tried a conditional statement?

 if (condition is true)
> {
>     // load div;
> }
1

Ok so now you have explained what you actually are trying to do.

You can use the jQuery .load() method with a callback that hides the spinner once the div gets loaded.

 $(selector).load(url,data,callback);

Here is an example...

 $( "#div1" ).load( "ajax/test.html", function() {
       $("#spinner").hide();
  });

So I assume you have a button on the page to start some process. At that time, show the spinner and start the load process. With the example I gave you above, hide the spinner during the callback phase.

I'd recommend you take a look at this js spinner rather than using an animated gif. I use this in all my projects now.

http://fgnass.github.io/spin.js/

Que tenga un buen día

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.