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