Working with Ajax ... I cannot understand what is wrong here. The error occurs in the code: objUserID.innerHTML = username; . He believes the username variable is NULL. the username has data in it, because the following code confirms this: console.log ("user: [" + username + "]"); Can anyone figure this out?
function actionBid(bidID,bidA,bidAction){
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest)
{
XMLHttpRequestObject = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
if(XMLHttpRequestObject)
{
if (bidAction == "getbid"){
var objUserID = document.getElementById("curBidUser"+bidID);
var res = XMLHttpRequestObject.responseText;
var username = res.substring(0,res.indexOf(','));
console.log("user: ["+username+"]");
objUserID.innerHTML = username;
}
}
}
Sammy source
share