我在发送数据时遇到了ajax问题。 Ajax返回ParseError我不知道为什么。任何帮助,将不胜感激。AJAX返回ParseError
function redeem_all_pts(co_id) {
var path = base_url+"cmaster/redeem_all";
$.ajax({
type:'POST',
url:path,
data:'co_id='+co_id,
dataType:'json',
success: function(resp) {
console.log("success!!="+resp);
},
error:function(resp, error) {
console.log(error);
}
});
}
其中作为我的PHP函数是
public function redeem_all() {
$user_id = $this->session->userdata('user_id');
if (!empty($user_id)) {
$co_id = $this->input->post('co_id');
$this->db->set('co_ytd_points','0', false);
$this->db->where('co_id' , $co_id);
} else {
$this->load->view('pages/login');
}
}
当我调试上谷歌浏览器的代码是确切的错误:
RESP =对象{readyState的:4,responseText的: “” ,状态:200, statusText:“OK”},error =“parsererror”
ParseError *什么,在哪里?* –
包括你请了整个错误。 – Sander
所以收到的数据不是一个有效的json ...你有没有通知或smth? –