show spinner gif while data is retrieving

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anudu
    New Member
    • Oct 2007
    • 31

    show spinner gif while data is retrieving

    Hi,

    I am developing a system using asp.net, ajax and javascripts. I have an interface that display user details. when the user enters the Id and press search button the user details will be retrieved from the database and showed in the fields. i use a javascript function that calls an ajax method in the server side.

    while the system is retrieving data from the database I want to display a spinner gif as in this link http://www.mpire.com/images/sunbox_spinner.gif . this gif file is saved in a local folder. I tried with setting visibility=' visible' of the gif at the begining of the search finction and setting it 'hidden' at the end. but it didn't work.

    can anyone help me?
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    please post the code you used and which is not working ... so that we may have a closer look at this. usally visibility should work while display = 'none' or 'block' should work too ... how did you refer to the image? when did you try to set the state of it?

    kind regards

    Comment

    • anudu
      New Member
      • Oct 2007
      • 31

      #3
      This is the javascript code

      [CODE=javascript]function searchCustomerI nfo()
      {



      document.getEle mentById("img1" ).style.visibil ity = "visible";

      // the code to get data from data base and set to fields
      //
      //
      document.getEle mentById("img1" ).style.visibil ity = "hidden";

      return false;


      }[/CODE]

      as I realized that if I commented the line to hide the image , the image was shown on the interface but only after all the other actions were completed.
      Last edited by gits; Apr 22 '08, 11:24 AM. Reason: added code tags

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        this line:

        [CODE=javascript]document.getEle mentById("img1" ).style.visibil ity = "hidden";[/CODE]
        should be called in the onreadystatecha nge-handler when the response is ready ...

        kind regards

        Comment

        • jcumoletti
          New Member
          • Apr 2008
          • 6

          #5
          you also have to make sure you are doing thins asyncronously or the gif wont animate

          Comment

          Working...