Forum Moderators: open
if(value.length > 3) {
var xmlHttp = createXmlHttpRequestObject();
var params = "boo=" + value;
var url = 'boo.php';
xmlHttp.open("POST",url, true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader('Cache-Control', 'no-cache');
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
var textResponse = xmlHttp.responseText;
if(textResponse == 0) {
document.getElementById('usr').value = "";
document.getElementById('usr').focus();
document.getElementById('servresp').innerHTML = "Hakuna matata!";
}
}
}
xmlHttp.send(params);
}
else {
document.getElementById('usr').value = "";
document.getElementById('usr').focus();
document.getElementById('servresp').innerHTML = "Booyakaa!";
}
document.getElementById('servresp').firstChild.nodeValue='Booyakaa!';
When you try to use JavaScript to interact with elements (such as giving focus or calling by ID) if they were loaded via JavaScript they will fail.
I don't have the time to create a stand-alone test case though if you want to create one and try to give focus to an anchor loaded via AJAX/innerHTML after the AJAX connection has closed.