用ajax返回了一个json数据 现在想遍历这个数据,结果都是undefine
js $().ready(
function() {
$(".btn_Search").click(function() {
$.ajax({
type: "POST",
url: "SmsSend.aspx/GetUserMobile",
data: "{'uId':'willson'}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(msg) {
alert(msg.d);
$('.td-serchUser').html("");
$.each(msg.d,function(i){
$('.td-serchUser').append("<div lang='"+msg.d[i].MOBILE+"' id='mail"+msg.d[i].U_ID+"'>"+msg.d[i].TITLE+"</div>")
})
}
})
//alert('123');
})
}
)
一部分json代码:
{ 'U_ID':'WILLSONCHAN111', 'TITLE':'xxx', 'MOBILE':'13400000000'},{ 'U_ID':'WILLSONCHAN221', 'TITLE':'xxx', 'MOBILE':'13400000000'},
js $().ready(
function() {
$(".btn_Search").click(function() {
$.ajax({
type: "POST",
url: "SmsSend.aspx/GetUserMobile",
data: "{'uId':'willson'}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(msg) {
alert(msg.d);
$('.td-serchUser').html("");
$.each(msg.d,function(i){
$('.td-serchUser').append("<div lang='"+msg.d[i].MOBILE+"' id='mail"+msg.d[i].U_ID+"'>"+msg.d[i].TITLE+"</div>")
})
}
})
//alert('123');
})
}
)
一部分json代码:
{ 'U_ID':'WILLSONCHAN111', 'TITLE':'xxx', 'MOBILE':'13400000000'},{ 'U_ID':'WILLSONCHAN221', 'TITLE':'xxx', 'MOBILE':'13400000000'},
解决方案 »
- firefox firebug的debug快捷键怎么像eclipse一样可以修改
- js代码失效困惑
- window.open下载文件,急求高手!
- 请大侠们帮忙看一下EXT中,从EditorGrid中删除行出总是报错
- 图片总是往上多走一个
- (让插入到 innerHTML 中的 script 跑起来)问题
- <textarea onpropertychange="value=value">dddddddd </textarea> 为什么报错?
- oUl.getElementsByTagName('li') 这个不执行
- 关于文本框的Disabled和ReadOnly
- 哪有div和span的资料可查?
- jquery 地址链接
- JS怎么根据STRING调FUNCTION
{ 'U_ID':'WILLSONCHAN111', 'TITLE':'xxx', 'MOBILE':'13400000000'},{ 'U_ID':'WILLSONCHAN221', 'TITLE':'xxx', 'MOBILE':'13400000000'},?
最后是个逗号的话 要干掉的 。不然解析不了 。
jsonStr = window["eval"]("(" + data.d + ")"); 接收一个对象集合
==> alert(msg.length);msg是个数组,里面的每个元素都是个JSON