总报xmlHttp is not defined 为什么啊?<body>
<form method="post">
<input type="text" name="username"/>
<input type="password" name="password"/>
<div id="gbqfb" class="ajax-sub" type="submit" onclick="substi();">登陆</div>
</form>
<div id="retu"></div>
</body>
</html>
<script>function substi()
{
var name=document.getElementsByTagName("input")['username'].value;
var pass=document.getElementsByTagName("input")['password'].value;var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("retu").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","login.php?cc="+new Date().getTime());
post="userNo="+name+"&pwd="+pass;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send(post);
}
</script>
<form method="post">
<input type="text" name="username"/>
<input type="password" name="password"/>
<div id="gbqfb" class="ajax-sub" type="submit" onclick="substi();">登陆</div>
</form>
<div id="retu"></div>
</body>
</html>
<script>function substi()
{
var name=document.getElementsByTagName("input")['username'].value;
var pass=document.getElementsByTagName("input")['password'].value;var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("retu").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","login.php?cc="+new Date().getTime());
post="userNo="+name+"&pwd="+pass;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send(post);
}
</script>
解决方案 »
- 弹出多个窗口的问题
- ppg网站上的这种效果是怎样实现的啊
- 一个如何调用js的问题
- frameset的问题 帮帮忙 谢谢
- 关于全角与半角的转换(正则式或JS函数),谢谢大家!
- 谁对ICAST技术有过研究的?就是新浪右下角弹出的那个视频播放的窗口?
- 奇怪!!!当光标在文本框中时按"回车"键页面竟然提交,怎样禁止这种文本框回车提交事件但又不影响button按钮的回车提交?
- 为始末这个javascript显示的日期与系统不一样呢?
- 在一个frame里面包含一个含有框架的网页,请问怎样调用??
- 请问与parent.close()相对的子窗口如何写
- 怎样用JavaScript来弄,从linux到windows文件格式中的换行符转换。
- 怎么样用jquery实现拖动鼠标的时候,鼠标后面带有个小图片一起移动
var name = document.getElementsByTagName("input")[0].value;
var pass = document.getElementsByTagName("input")[1].value; var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("retu").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("POST", "login.php?cc=" + new Date().getTime());
post = "userNo=" + name + "&pwd=" + pass;
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(post);
}
搞了1小时也没发现少了个h,后来粘贴过来还是莫名其妙的发现好了哎
var name = document.getElementsByTagName("input")[0].value;
var pass = document.getElementsByTagName("input")[1].value;
这2种不知道GG支持不?
我用前面的IE FF都可以。。
getElementsByTagName() 方法可返回带有指定名称的所有元素的一个节点列表。文档树中具有指定标记的 Element 节点的只读数组(从技术上讲,是 NodeList 对象)。返回的元素节点的顺序就是它们在源文档中出现的顺序。http://www.w3school.com.cn/xmldom/dom_nodelist.asp
NodeList 对象
我们可通过节点列表中的节点索引号来访问列表中的节点(索引号由0开始)。