0

我的 jquery ajax 函数和 php 响应请求有问题。问题是,当请求 url 不存在时,响应状态仍然是 200;

ajax 函数如下

        $.ajax({
            type: "post",
            url: "http://localhost/project/Show/async/",//  if this address is exists
            /**url: "http://localhost/project/Show/async-1/*",*/  //this is wrong address
            data:$dataJson,
            beforeSend: function(XMLHttpRequest){
                alert('send before');
            },
            cache:false,  
            success: function(data, textStatus){
                alert(success);
            },
            error : function() {    
                alert("sorry , error!"); 

            },
            complete: function(XMLHttpRequest, textStatus){
                //HideLoading();
            },
        });

php代码很简单:

      $response = self::parse2String($_REQUEST);
      var_dump($response);

状态 /async 和 /async-1 的响应都是 200

需要你帮忙!

4

0 回答 0