发送php响应给ajax

好的,我有一个 PHP脚本,结尾如此:
if ($success)
{
    $result = array('success' => true);
}
else
{
    $result = array('success' => false,'message' => 'Something happened');
    header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error',true,500);
}
  echo json_encode($result);

还有一些jquery,我计划在我的脚本运行时提醒我.

jQuery(document).ready(function() {

    $.ajax({
        url: './contactengine.PHP',type: 'GET',dataType: 'JSON',success: function(response) {
                        alert("GOOD");
                },error: function() {
                        alert("BAD");
                }
    });

});

编辑来源

<?PHP 
        if ($success){
             $result = array("status" => "1");

             echo json_encode($result);
            }
            else{
              print "<Meta http-equiv=\"refresh\" content=\"0;URL=/404.html\">";
            }    
        ?>
        <script>
        jQuery(document).ready(function() {

          $.ajax({
                           type: 'GET',url:  'Thatscriptsomething.PHP',cache: 'false',dataType: 'json',success: function(response) {
                               if(response.status == "1") {
                                    alert("we having a working script");
                               } else {
                                    alert("Oops,script is a no go");
                               }
                            }
                        });
        });
        </script>

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...