$ .each()循环未被调用

时间:2013-03-24 23:22:42

标签: jquery ajax json

$.ajax({
                    url: '@Url.Action("Ajax_GetCartOrders","Business")',
                    type: 'POST',
                    data: JSON.stringify(email),
                    dataType: 'json',
                    processData: false,
                    contentType: 'application/json; charset=utf-8',
                    success: function (result) 
                    {

                            alert("success"); // this works
                            alert(result);    //this works and shows the correct data

                            $.each(result, function () 
                            {
                               alert("inside loop");// this doesnt work
                            });
                    },

为什么$ .each里面的闹钟不起作用? 成功警报有效,警报结果显示正确的json数据

 result data

    {"id":6,"email":"TEST","date":"TEST","relation":"TEST"},       {"id":7,"email":"TEST","date":"TEST","relation":"TEST"},{"id":8,"email":"TEST","date":"TEST","relation":"TEST"},{"id":9,"email":"TEST","date":"TEST","relation":"TEST"},{"id":10,"email":"TEST","date":"TEST","relation":"TEST"},{"id":11,"email":"TEST","date":"TEST","relation":"TEST"},{"id":12,"email":"TEST","date":"TEST","relation":"TEST"},{"id":19,"email":"TEST","date":"TEST","relation":"TEST"},{"id":3,"email":"testemail","date":null,"relation":null}]

1 个答案:

答案 0 :(得分:0)

这似乎有效:

$(result).each(function(){
    console.log(this.email);
})

http://jsfiddle.net/22BBv/