Ajax problem?

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?

Mar.22,2021

1. Press F12 to view the returned result of network request
2, TP framework should have a way to return json data
3. The communication between front and rear interfaces returns Boolean value unreliable. Judge whether the request is successful or failed by returning code frontend


if($result>0){
    echo 'true';
}else{
    echo 'false';
}

var name = document.getElementById("name").value;
var url = "{:U('/Home/User/check',array('name' => name))}";
//:
var url="{:U('Home/User/check'}"+"/name/"+name;
//F12
.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44fff-43835.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44fff-43835.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?