the js code is as follows:
function send() {
var xml = new XMLHttpRequest();
xml.onreadystatechange = function () {
if(xml.readyState==4 & xml.status==200){
if(xml.responseText=="true"){
document.getElementById("hide_info").innerHTML = "";
}else {
document.getElementById("hide_info").innerHTML = "";
}
}
}
var name = document.getElementById("name").value;
var url = "{:U("/Home/User/check",array("name" => name))}";
xml.open("GET",url,true);
xml.send(null);
}
HTML Code:
<span class="reg_text">:<input type="text" name="name" id="name" onblur="send()"></span><span id="hide_info"></span><br/>
Controller Code:
public function check(){
$name = I("get.name");
$user = D("User");
$result = $user->field("name")->where(array("name" => $name))->find();
if($result>0){
return true;
}else{
return false;
}
}
I want to test user name detection, but it can"t be implemented. Is there a problem?