逗人, 我调用ajax函数时出错了。
SyntaxError: Unexpected token < in JSON at position 8
at JSON.parse (<anonymous>)
at parseJSON (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)
at vo (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)
at k (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)
at XMLHttpRequest.u (jquery?v=M6dmVkrHVhoZ1gfOtvVDZbgBcQTsbWxoLsRizcGkbPk1:1)
这是我的ajax呼叫代码:
function MyFunction() {
$.get("/Base/TestMethod", { message: 'nice' }, function (data) {
console.log(data);
}, 'json').fail(function (jqXhr, textStatus, errorThrown) {
alert(textStatus + ": " + errorThrown + ": " + jqXhr.responseText);
console.log(errorThrown);
});
}
答案 0 :(得分:0)
就我而言,返回的JSON太大。尝试将MaxJsonLength设置为最大int值。
public function getAgeAttribute()
{
$now = Carbon::now();
return Carbon::parse($this->attributes['created_at'])->diffInMonths($now);
}