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
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...
  }
}

Link to comment
Share on other sites

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"

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.