阿贾克斯成功后循环JSON响应 [英] Loop JSON response after ajax success
本文介绍了阿贾克斯成功后循环JSON响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
很抱歉,这是从<一个重复href="http://stackoverflow.com/questions/733314/jquery-loop-over-json-result-from-ajax-success">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]);
}
这篇关于阿贾克斯成功后循环JSON响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文