Hello and welcome to our community! Is this your first visit?
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
    Apr 2010
    Thanked 0 Times in 0 Posts

    Question Ajax Javascript Response

    hey guys!

    i was trying out some form submit ajax code. It goes like this.

    A Blank box is there. Clicking a link updates the blank box content to contain a form and a javascript. A PHP file gives the responsetext.

    response text is something like this:

    onsubmit event handler.

    but it is not working. It is as if on submitting the onsubmit handler is not getting activated.

    Help plz!!

  • #2
    Regular Coder
    Join Date
    Feb 2009
    NJ, USA
    Thanked 70 Times in 69 Posts
    Unfortunately, the browser doesn't automatically parse and execute scripts when you add them dynamically like that.

    There are a few forum posts out there about this though, try searching google for "execute script ajax" or something along those lines.

    Did see one post that might be a solution though: http://www.webdeveloper.com/forum/sh...d.php?p=917682. What you would do is run this guy's function with your responseText, and it would execute the code in the script tags, and return the HTML with the script tags stripped out. You would then use that return value in your innerHTML.

    // (include that post's parseScript function here)
    function handleResponse( ajaxObj ) {
      if( ajaxObj.readyState == 4 ) {
        var myDiv = document.getElementById( 'myDiv' );
        myDiv.innerHTML = parseScript( ajaxObj.responseText );
    Try that and let me know how it goes.



    Tags for this Thread

    Posting Permissions

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