0
當訪問從MongoDB文檔返回JSON的請求時,我看到一個奇怪的解析器錯誤(parsererror)。MongoDB _id字段上的jquery ajax解析器錯誤
該文件返回一個晦澀parsererror:
{"data":{"first_name":"Ray","last_name":"Reinger","_id":4e9c0ed27763dfba37000001}}
本文件並不返回錯誤:
{"data":{"first_name":"Ray","last_name":"Reinger"}}
正在使用jQuery是:
$("#fetch").click(function(){
var url = "http://localhost:3333/people/4e9c0ed27763dfba37000001";
$.ajax({
url: url,
method: 'GET',
success: function(data, status){
//do a thing with the data
},
complete:function(jqXHR, status) {
console.log(status) //displays 'parsererror'
}
});
return false;
});
請求本身是好的。 返回的MIME類型是'application/json'。 所有的字段和值都被引用。 _id是有效的JSON,只要我可以groh。
基本上打開和關閉_id使事情工作。