阿贾克斯成功后循环JSON响应阿贾克斯、JSON

2023-09-10 16:58:23 作者:我们的爱再也回不来?

很抱歉,这是从here问左右,但我是新来这个,所以我想知道如何做到这一点?

Sorry this is a duplicate from here asked in SO but I'm new to this so I would like to know how to do it?

这是我的ajax调用:

This is my ajax call:

  $("#btnprocess").click(function () {
                $.ajax({
                    type: "POST",
                    url: "Default.aspx/GetFilenames",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        alert(response.d[0]);
                        alert(response.d[1]);
                      }
                });
  });

独立我能够得到的回应,但我需要循环它们。

Individually I'm able to get the response but I need to loop them.

任何人都可以说,我该怎么办呢?

Can anyone say me how do I do this?

推荐答案

您可以做;

for (var i=0; i<response.d.length; i++) {
 alert(response.d[i]);
}
 
精彩推荐
图片推荐