Jump to content

[SOLVED] show hide loading


dlf1987

Recommended Posts

could sum1 help me add a show hide feature to this function... its a sortable lists from phpriot, how could you make it so that when this function starts its shows a div saying "updating database", and when the function ends it hides the div.

 

function updateOrder()
{
    // turn on update message here

    var options = {
                    method : 'post',
                    parameters : Sortable.serialize('movies_list'),
                    onComplete : function(request) {

                        // turn off update message here

                    }
                  };

    new Ajax.Request('processor.php', options);
}

 

i commented where i think ??? the on off should go

 

hope it makes since...

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/51342-solved-show-hide-loading/
Share on other sites

I don't know what type of Ajax library you are using. :-\

It seems like you need a status teller to tell you what is the AJAX status right now.

 

For the most commonly, it should be like this:

 

httpRequest.onreadystatechange = handle;

function handle(){
  if(httpRequest.readyState == 4){
    //done loading.
  }else{
    //loading...
  }
}

function updateOrder()
{
    // turn on update message here
    document.getElementById('yourdivID').innerHTML = 'updating...';

    var options = {
                    method : 'post',
                    parameters : Sortable.serialize('movies_list'),
                    onComplete : function(request) {

                        // turn off update message here
                        document.getElementById('yourdivID').innerHTML = '';
                    }
                  };
    new Ajax.Request('processor.php', options);
}

 

create a div somewhere in your page with id="yourdivID"

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.