xml.responseText没有做任何事情 [英] xml.responseText not doing anything

查看:155
本文介绍了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/


这篇关于xml.responseText没有做任何事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆