tp3.2.3项目移植到线上后,jQuery ajax请求出现parseerror问题

浏览:821 发布日期:2017/02/24 分类:求助交流 关键字: parseerror
tp项目本地是好的,但移植到线上后,jQuery ajax请求服务器后不执行success函数,却执行error函数,在error函数里打印的错误信息为pareerror。

服务器端代码
public function getAjax() {
$data = array('a'=>123);
$this->ajaxReturn($data,'json');
}
前端代码
$.ajax({
url : APP + '/Test/getAjax',
type : 'post',
dataType : "json",
data : {},
success : function (msg) {
console.log(msg);
},
error: function() {
console.log(arguments[1]);
}
});

服务器端返回的数据
{"a":123}
----------------------------------------------------------------------
同样在这个服务器上,不用tp框架,jQuery ajax请求后能执行success函数

$.ajax({
type: 'get',
async:false,
url: 'index.php?a=1',
data: {},
dataType: 'json',
success: function(data) {
alert(data['success']);
},
error:function(data) {
console.log(data);
console.log(arguments[1]);
}
});
服务端代码
<?php
echo json_encode(array("success"=>"fdfsd"));

页面请求后弹出 fdfsd
最佳答案
评论( 相关
后面还有条评论,点击查看>>