PHP Loading Image..HELP!

Discussion in 'PHP' started by zealot777, Dec 19, 2009.

  1. #1
    Hello,

    Anybody knows how to do that a loading image is being shown while the script is being processed? And when the script has finished loading a message will be displayed that process is completed. As I want to add that feature to my mailer. Thanks in advance!
     
    zealot777, Dec 19, 2009 IP
  2. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #2
    You'll need to use jQuery (yes, you can use any javascript framework, etc).

    Have a div called "loading", and an image called "loading.gif".

    function send_message()
    {
       $("#loading").innerHTML = "<img src='loading.gif'>";
    
       $.post(url, [data], function(){
          $("#loading").innerHTML = "";
       });
    
    }
    HTML:
    That basically inserts an IMG tag into the div #loading, then does an AJAX post to 'url', and when it's done, clears #loading of the img tag. There are other ways to do this (and this example itself may need some tweaking), but this is how it's basically done.
     
    Wogan, Dec 20, 2009 IP