ajax遍历data返回的数组
function showFindConcatDialog(mobile,uid){ $("#concatListsDialog").dialog("option", "title", "联系人显示列表"); $.ajax({ url: "findConcatinfo.action", type:"post", dataType:"json", data:{mobile:mobile,uid:uid}, success: function(data){ if (data.tip == null) { var co= data.userConcatList; var html = "<table style='font-size:16px;'><thead style='color:#1c94c4'><tr><th width='100' style='padding:5px;'>姓名</th><th width='200' style='padding:5px;'>手机</th><th width='100' style='padding:5px;'>邮箱</th></tr></thead><tbody align='center'>"; $.each(co,function(i,n){ html +="<tr><td style='padding:5px;'>"+n.realname+" </td><td style='padding:5px;'>"+n.mobile+"</td><td style='padding:5px;'>"+n.email+"</td></tr>"; }); html += "</tbody></table>" $("#concatListsDialog").html(""); $("#concatListsDialog").html(html); $("#concatListsDialog").dialog("open"); } else{ alert(data.tip); } } }); }
当然也可以直接用for遍历:
var json = {"options":"[{\"text\":\"王家湾\",\"value\":\"9\"},{\"text\":\"李家湾\",\"value\":\"10\"},{\"text\":\"邵家湾\",\"value\":\"13\"}]"} json = eval(json.options) for(var i=0; i<json.length; i++) { alert(json[i].text+" " + json[i].value) }
href="javascript:showCommRecharge();"
相关推荐
Masimaro 2020-06-14
kaixinfelix 2020-10-04
liuyang000 2020-09-25
kikaylee 2020-11-11
nongfusanquan0 2020-09-23
aanndd 2020-08-12
Tips 2020-08-08
waitwolf 2020-07-30
81264454 2020-07-17
shenxiuwen 2020-07-05
roseying 2020-07-04
清溪算法君老号 2020-06-27
OldBowl 2020-06-26
dugujiujian 2020-06-25
oXiaoChong 2020-06-20
晓杰0 2020-06-14
vincen 2020-06-12
Jasmineyaoyao 2020-06-08