用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'},

解决方案 »

  1.   

    一部分json代码:
    { 'U_ID':'WILLSONCHAN111', 'TITLE':'xxx', 'MOBILE':'13400000000'},{ 'U_ID':'WILLSONCHAN221', 'TITLE':'xxx', 'MOBILE':'13400000000'},?
    最后是个逗号的话 要干掉的 。不然解析不了 。
      

  2.   

    首先msg.d是字符串还是json的格式,搂住可以看看然后试试把$.each改成for循环看能不能用 
      

  3.   

        var jsonStr = "";
    jsonStr = window["eval"]("(" + data.d + ")");  接收一个对象集合
      

  4.   

    json的  数据包格式注定了 你得用 $.each  找到索引行
      

  5.   

    看看返回的json是否错了,如果是json数组格式应该是这样:[{ 'U_ID':'WILLSONCHAN111', 'TITLE':'xxx', 'MOBILE':'13400000000'},{'U_ID':'WILLSONCHAN221', 'TITLE':'xxx', 'MOBILE':'13400000000'}]
      

  6.   

     alert(msg.d);
    ==> alert(msg.length);msg是个数组,里面的每个元素都是个JSON