0
$.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}]
4

1 に答える 1

0

これはうまくいくようです:

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

http://jsfiddle.net/22BBv/

于 2013-03-24T23:54:07.367 に答える