Trying to call JS Code that is passed back from AJAX call....

Posted by Dutchie432 on Stack Overflow See other posts from Stack Overflow or by Dutchie432
Published on 2010-06-11T20:23:05Z Indexed on 2010/06/11 20:32 UTC
Read the original article Hit count: 159

Filed under:
|

Okay, so I have an javascript function that retrieves some HTML...

function updateQuestions(i){
    var url = 'getQuestions.php?sys=' + i;
    if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
        receiveReq.open("GET", url, true);
        receiveReq.onreadystatechange = handleQuestionsUpdate; 
        receiveReq.send(null);
    }
}

function handleQuestionsUpdate() {
    if (receiveReq.readyState == 4) {
        var a=receiveReq.responseText;
        document.getElementById('questions').innerHTML=a;
        checkSpeakers(); //Error Occurs Here, even though checkSpeakers() is a function in the returned HTML chunk.
    }   
}

This HTML is not just HTML, but it is more specifically a form and a chunk of javascript. The javascript is hard-coded into the HTML and not referenced by <script src="..">

Is it normal that this retrieved JS code isn't recognized upon call-time? If so, what is my alternative if I need the JS to change every time the div is update?

Now

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX