xml.responseText没有做任何事情

问题描述:

大家好,我已经制作了一个非常基本和简单的代码,其中我有一个输入字段,该字段在每个按键上都有效但当我在表单中输入任何内容时没有任何反应,当我写下document.getElementById('show') .innerHTML =任何东西;它在div中显示任何东西,但是当我写下document.getElementById('show')。innerHTML = xmlHttp.responseText;它没有显示任何想法?



这是我的index.html文件



hello everyone , i have made a very basic and simple code in which i have an input field which is validated on every keypress but when i enter anything in the form nothing happens , when i write document.getElementById('show').innerHTML = "anything"; it shows "anything" in the div but when i write document.getElementById('show').innerHTML = xmlHttp.responseText; it shows nothing , any ideas???

this is my index.html file

<script type="text/javascript">
    var xmlHttp = new XMLHttpRequest();         
    function validate(user){                    
            xmlHttp.open("GET", "names.php", true);            
            xmlHttp.onreadystatechange = function(){
                document.getElementById('show').innerHTML = xmlHttp.responseText;
            }
    xmlHttp.send(null);
    }
</script>
<h2>Enter a muslim name :</h2>
<form>
    <input type="text" onkeypress="validate(this.value)" />
                <div id="show"></div>
</form>

http://forums.phpfreaks.com/topic/156770-solved-doing-a-loop-with-xmlhttpresponsetext/
http://forums.phpfreaks.com/topic/156770-solved-doing-a-loop-with-xmlhttpresponsetext/