4 Years
Discussion Span
Last Post by centenond

Have you tried a conditional statement?

if (condition is true)
    // load div;

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

Have you tried a conditional statement?

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

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.


Here is an example...

 $( "#div1" ).load( "ajax/test.html", function() {

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.


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.