thread1600-1279426
I hope the thread reference above works. I tried both methods and could not get either to work, but I may have misunderstood.
I am trying to use AJAX to load some new form fields into the page. Once those fields are loaded, I need to initialize and load some values from those fields into arrays. It seems no matter what I do, the init and load code runs before the form fields are added and I get errors.
Sample Code:
In the sample above, initializeArrays() and loadValues() end up being executed before div_id is updated. How can I prevent this?
From the reference thread, I tried changing the open parm to false and that did not work. I also tried setting up a new function called loadArrays that called the init and load values functions and then passing it in as mentioned in that thread and that did not work for me either. What am I doing wrong?
-Greg
I hope the thread reference above works. I tried both methods and could not get either to work, but I may have misunderstood.
I am trying to use AJAX to load some new form fields into the page. Once those fields are loaded, I need to initialize and load some values from those fields into arrays. It seems no matter what I do, the init and load code runs before the form fields are added and I get errors.
Sample Code:
Code:
function generateFields() {
var xmlhttp = createXMLHttpRequest();
if (xmlhttp) {
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("div_id").innerHTML = xmlhttp.responseText;
initializeArrays();
loadValues();
} else {
document.getElementById("div_id").innerHTML = "<img src=\"loading.gif\" />";
}
}
strURL = "ajax_handler.asp";
xmlhttp.open("GET", strURL, true);
xmlhttp.send(null);
}
}
In the sample above, initializeArrays() and loadValues() end up being executed before div_id is updated. How can I prevent this?
From the reference thread, I tried changing the open parm to false and that did not work. I also tried setting up a new function called loadArrays that called the init and load values functions and then passing it in as mentioned in that thread and that did not work for me either. What am I doing wrong?
-Greg