TypeError: invalid 'in' operand obj

尝试在程序去访问远程的Web API,它在运行时,出现异常:

TypeError: invalid 'in' operand obj

TypeError: invalid 'in' operand obj

由于从服务器返回的数据是json。
当我们需要得到这些数据时,还得需要Parse。
因此我们把代码稍微修改一下:
TypeError: invalid 'in' operand obj

 
$(function () {
$.ajax({
type: "GET",
url: "http://localhost:9001/api/size",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
data = $.parseJSON(data);
$.each(data, function (index, item) {
//...
}); },
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
});

Source Code

上一篇:Elasticsearch学习1--head插件安装


下一篇:org.gradle.process.internal.ExecException: