我正在开发一种用户必须插入用户名的表单。我想检查模糊用户的用户名是否有效:
我添加了这个脚本:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
在 HTML 中:
<input name="username" type="text" onblur="checkUsername()">
脚本:
function checkUsername(){
var usn = document.getElementsByName('username')[0];
if(usn.value != "") {
var html = $.ajax({
type: "GET",
url: "checkUsername.php?",
data: "usr=" +usr.value
async: false,
dataType: "text"}).responseText;
if(html == "si") {
usn.style.backgroundColor = "green";
} else {
usn.style.backgroundColor = "red";
usn.value = "Username still exists!";
}
}
}
所以onBlur
不起作用,当我提交表单时出现如下错误:
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
我能做些什么?哪里有问题?