JavaScript errors trying to add event listeners for onclick() using DOM and AJAX

Discussion in 'Javascript' started by donpro, Oct 29, 2007.

  1. donpro

    donpro Guest

    Hi,

    I have PHP file called file1.php with an empty <div></div> in the
    middle. I've added a 'load' event listener so that on page load, it
    calls an AJAX function that calls file2.php. file2.php creates a
    table and loads it into the <div></div> in file1.php.

    file2.php has <a> tags in it's <th> columns and I wish to trap when a
    user clicks on the column heading. The old way was to use the
    onclick() method but I'd rather use event listeners.

    Here's my problem. I am getting "obj has no properties" when trying
    to add those listeners. I *think* it is because the code in file2.php
    isn't part of the original DOM tree for file1.php. So how can I use
    event listeners instead of onlclick()? I know I can add top the DOM
    by creating elements and appending them but that adds to the HTML code
    and my code is already in place via the AJAX call.

    What to do...? DO I just use the old passe onclick() method?
     
    donpro, Oct 29, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    92
  2. SM
    Replies:
    4
    Views:
    95
  3. donpro
    Replies:
    1
    Views:
    104
    Thomas 'PointedEars' Lahn
    Oct 29, 2007
  4. donpro
    Replies:
    0
    Views:
    97
    donpro
    Oct 29, 2007
  5. Matt Kruse
    Replies:
    2
    Views:
    180
Loading...

Share This Page