The full code relating to this question can be found at
http://marc.info/?l=php-general&m=112198633625636&w=2
It describes a bare bones way of making an AJAX request.
It works fine for me except at the last step where data is put into an
innerHTML element within
<div id="foo">
</div>
Here is the function to do that:
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
// var up0 = update[0];
// alert("up0 is " + up0);
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
I get an error stating that getElementById(update[0]) is either null
or not an object>
Using the commented out alert code I have confirmed that the update
array does in fact contain "foo" in update[0].
If I hardcode the value "foo" into the line thus
document.getElementById("foo").innerHTML = update[1];
update[1] is displayed ok within the foo div without error
I would be gratefulif somone could explain to me what is causing this
error
TIA
N