以下是变量的值data
:
[{"pcode":"1","category":"Category_1","ptitle":"Title_1"},
{"pcode":"2","category":"Category_2","ptitle":"Title_2"},
{"pcode":"3","category":"Category_1","ptitle":"Title_3"}]
我的 jquery ajax 函数返回上面的数组。我使用下面的代码在页面上列出它们的详细信息。
$.each(data,function(ptitle,category){
$("#results").empty().append('<label>'+data.ptitle+' is in '+data.category+'</label><br>');
});
我想使用上面的代码显示的是:
Title_1 is in Category_1
Title_2 is in Category_2
Title_3 is in Category_1
但显示的是:
undefined: undefined