<script type="text/javascript">
/**
* 检查用户名是否存在
*/
function checkName(){
var xmlhttp;
var name = document.getElementById("user.username");
var values = name.value;
var username = document.getElementsByName("userName");
[color=red]var url = "isexist";//我的url[/color]
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
[color=red]xmlhttp.open('GET', url, true);//运行到这里就报错了(firebug报错)[/color]
xmlhttp.send("userName="+values);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readState == 4 && xmlhttp.status == 200) {
if ("yes" == xmlhttp.responseText) {
document.getElementById("user.userName").value = "";
alert("用户名已存在");
return;
}
}
};
}</script>
这是我的js,我的struts在下面:
/register.jsp
别的action都可以找到,因为本页面我定义了个form,提交的action直接写action名就可以了,但是我的ajax说什么页找不到action,包括加上绝对路径也不行