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

后端 未结 6 1251
傲寒
傲寒 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:34

    You're not sending the return value of the status() function back to PHP. Use:

    echo json_encode(status());
    

    And change the AJAX call to expect a JSON response.

    function check() {
        $.ajax({
            url: "status.php",
            dataType: 'json'
        }).done(function(data) {
            alert(data);
        });
    }
    

提交回复
热议问题