Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ajax write response in different span tags with an ID generated with PHP

    First of all, HI. it's my first post.
    I don't even know if this is the way to approach the problem, if not, please tell me. Here is what I am doing and what I want to do:

    JS to output server response:
    if(xmlHttp.readyState ==4)
    {
    document.getElementById("response").innerHTML =xmlHttp.responseText;
    }

    The HTML:
    <span id="response">Here comes the response:</span>


    I got this to work. However, I want the feedback to be in different spans depending on the unique id that I generate with PHP.

    <span id="response<?php echo $uniqueid; ?>">Here comes the response:</span>

    if the entry with id 5 is updated, i want the response to go to the span with response5 and no others.

    I don't know how to approach this problem.

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    however you're calling your ajax.... pass the id as an arg

    Code:
    <span id="<?php echo $uniqueid; ?>" onclick="domyajax('<?php echo $uniqueid; ?>');">Here comes the response:</span>


  •  

    Posting Permissions

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