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

后端 未结 6 1329
傲寒
傲寒 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

    Ajax may not be returning a boolean true or false, rather a string.

    So try and put true in double quotes:

    if(data=="true")

    You can also use the trim function on data to ensure no whitespace is present in the returned data, like so:

    if($.trim(data)=="true")

提交回复
热议问题