Results 1 to 1 of 1

Thread: Basic AJAX routine doesn't work in FOR Loop?

  1. #1
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Basic AJAX routine doesn't work in FOR Loop?

    Hi,

    I'm not very good with javascript/ajax but managed to get this
    example working:
    http://www.dynamicdrive.com/dynamici...jaxroutine.htm

    I've adjusted the getAjaxRequest function slightly to allow me to
    specify where the result goes 'divtoupdate' which is just an
    extra argument to the function.

    What i'm trying to do is have a button on a page that runs
    a loop updating a number of DIVS. It works OK except
    only the last DIV in the loop actually gets updated. I think
    this has something to do with the example code using
    global objects or something.. eg:

    for (x in divs_to_update)
    {
    updatediv = divs_to_update[x];
    ajaxpack.getAjaxRequest("example.php?id=" + updatediv, "", processGetPost, "txt", updatediv);
    }

    Only the last div name (stored on divs_to_update) is
    actually updated.. anyone know why?

    Can anyone please suggest what I need to change to have each
    call in the for loop actually actioned separately?

    Thanks a million,
    Adrian.
    Last edited by adrian.jfl; 07-09-2007 at 02:45 PM. Reason: better clarity on subject

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •