SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    0 Post(s)
    0 Thread(s)

    AJAX and originating element within the DOM?

    I have a list that looks like this:
    <li id="itema" onclick="doReq(this)">itema
    <li id="itemb" onclick="doReq(this)">itemb
    <li id="itemc" onclick="doReq(this)">itemc
    Onclick I do an ajax request to the server and with what I get back I expand the item that was clicked by building another list like so <ul><li>newitema<li>newitemb<li>newitemc, etc</ul>
    I do this not by using innerhtml but by expanding the DOM element.
    The problem I am having is identifying and addressing the item that was clicked, since I cannot pass a parameter client side to the onchangereadystate handler (it does not accept parameters). I could pass the value of 'this' to the server program and then feed it back, but 'this' comes out like 'liobject' or similar (depending on browser), and I cannot get this to work. Is there some other way I can go about this?


  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Cambridge, UK
    0 Post(s)
    0 Thread(s)
    You could pass the this reference to a global variable that is then used by the readystate handler; or you could put the id of the LI in the function call and use getElementById instead.


Posting Permissions

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