I am doing a response to php script.
<script >
function showHint(str) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
document.getElementById("result").innerHTML = xmlhttp.responseText;
};
xmlhttp.open("GET", "gethint.php?q=" + str, true);
xmlhttp.send();
} </script>
And after i call showHint(str), i do:
var result = document.getElementById("result");
And it's always null. But this works fine and gives a right text:
<p><span id = "result"></span></p>
What i am doing wrong?