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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

XAJAX and showing a loading image

  • 14-05-2007 7:01am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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