Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

XAJAX and showing a loading image

Options
  • 14-05-2007 8:01am
    #1
    Registered Users Posts: 648 ✭✭✭


    hi,

    on a blog component im making i have a little calendar.
    i have little buttons for next and previous months which are loaded via ajax.
    however thing is i would like to show a loading image for 2 seconds before i spit out the calendar. however it wont seem to work cos i can only call
    return $objResponse->getXML(); once .

    heres my function



    function NewMonth($m) {
    $objResponse = new xajaxResponse();

    $objResponse->addAssign("calendar", "innerHTML", '<img src="images/ajax-loader.gif"/>');
    $ret=showCalendar($m);

    $objResponse->addAssign("calendar", "innerHTML", $ret);
    return $objResponse->getXML();
    }


    because the last call to addAssign is to assign the calenar then i dont see teh loading image.

    anyone know how i can do this ?

    tnx


Comments

  • Registered Users Posts: 94 ✭✭Kudos


    I won't know what the problem is until I at least see what showCalendar is supposed to do. I can tell you this, you should be using dom to add the image, not a string. You should also initialise the image variable for your loading icon at the very beginning, this way it'll have already downloaded the image. Post more code if you want more help.

    Incidentally, a lot of ajax apps use setTimeout to give the image a second to display no matter how long the request takes.


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    Kudos wrote:
    I won't know what the problem is until I at least see what showCalendar is supposed to do. I can tell you this, you should be using dom to add the image, not a string. You should also initialise the image variable for your loading icon at the very beginning, this way it'll have already downloaded the image. Post more code if you want more help.

    Incidentally, a lot of ajax apps use setTimeout to give the image a second to display no matter how long the request takes.


    HI
    yes ive tryed settimeout,
    but the problem is that $objResponse->getXML(); sends everything back to the page at once (as far as im aware) therefore the timeout is finished at that stage so i only see the calendar.
    if i could use some sort of timeout that would sort my problem

    tnx

    ps : showCalendar() actually gets the html code for the specified months calendar


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    did you try using onclick to change the div content to your image using innerHtml?


Advertisement