How to get true or false from PHP function using AJAX?

后端 未结 6 1311
傲寒
傲寒 2021-01-23 14:31

I tested status.php return value with var_dump($result) and alerted it out in check() function like this:

function check() {
    $.ajax({
               


        
6条回答
  •  情深已故
    2021-01-23 14:42

    you just echo the $result like this

    ajax not returning value so that we have to echo it.

     
    

    and then should be like this

    function check() {
    $.ajax({
        url: "status.php"
    }).done(function(data) {
        if(data == "true"){
            alert("true");
        } else {
            alert("false");
        }
    });   }
    

提交回复
热议问题