有关TypeError: invalid 'in' operand obj的错误
var data: { name: "John", location: "Boston" }
$.each(data, function(key, val) { items.push('<li id="' + key + '">' + val + '</li>'); });
用$.each解析的时候,in对字符串不管用
修改代码为:
data: { name: "John", location: "Boston" } obj= $.parseJSON(data); $.each( obj, function(key, val) { items.push('<li id="' + key + '">' + val.name+ '</li>'); });