English 中文(简体)
jjjQuery AJAX 请求错误状态 0
原标题:jQuery AJAX request error status 0
  • 时间:2012-05-25 06:06:51
  •  标签:
  • ajax
  • jquery

我一直在本地开发一个应用程序, 并在实际服务器上遇到麻烦。

每次我向 jQuery 提交 AJAX 请求时, 它会给我错误 < code> status: 0 和 statusText: 错误

铬检查员甚至没有显示 请求的回复代码, 它只是说失败了。

当我更近一点地检查它时,我注意到所有的数据都发送了,而PHP文件也实际处理了。例如,在下面的请求中,用户确实创建了。错误的响应代码阻止了其他请求(因为它们取决于成功响应)的执行。

以下是一项抽样请求:

var cct = $.cookie( ttc_csrf_cookie ); // csrf protection
var sUrl = "<?= base_url(); ?>user/create/";
var serialized = { 
    name: me.name, 
    email: me.email, 
    oauth_provider:  facebook , 
    oauth_uid: me.id,
    ttc_csrf_token: cct
};
$.ajax({
    url: sUrl,
    type: "POST",
    data: serialized,
    error: function(someStuffHere) {
            //* THIS CODE RUNS. SHOWS ERROR STATUS: 0 */
    },
    success: function(user_id) {
        //******** THIS HERE NEVER RUNS ***********///    
    }
});

以下是相应的PHP代码:

public function create() {
    if($this->input->post()) {
        $user[ name ] = $this->input->post( name );
        $user[ email ] = $this->input->post( email );
        $user[ oauth_provider ] = $this->input->post( oauth_provider );
        $user[ oauth_uid ] = $this->input->post( oauth_uid );
        $user[ last_activity ] = date( Y-m-d H:i:s );

        $user_id = $this->Users->create_user($user);
        $this->session->set_userdata( user_id , $user_id);
        echo $user_id;
    }
}

这两个片段只是一个例子。AJAX的所有要求都无法解决活的断裂问题。

会是什么?

< bronger> UPATE: 我缩小了范围, 当回响结果时会发生问题。 当我评论回声时, 没有错误( 但是当然没有发送结果 ) 。

问题回答

发现这个问题是由 CodeIgniter 中的 press_output 选项引发的。 当它设定为真时, echo 无法工作。 感谢大家的帮助!





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签