html代码:
实现代码如下:

<table id="repTable"……>
……
<span id="<%# Eval("Id") %>" class="address"></span>
</table>

jquery代码:

实现代码如下:

$(document).ready(function(){
$("#repTable span.address").each(function(){
var spanTemp = $(this);
$.ajax({
type: "get",
url: "SceneryAjaxCall.aspx",
data: "sid="+$(this).attr("id"),
cache: true,
dataType: "html",
success: function(msg){
spanTemp.append(msg);
}
});
});
});


其中在写jquery代码时,我遇到了下面几个问题:

(1)开始没写第三行,而是在第十一行直接调用的$(this),报错“不能给回调函数赋值”。原因是回调后对象已经发生改变,所以需要事先保存;

(2)没写dataType,发现不能返回msg,不知道为什么;

以上就是【jquery异步循环获取功能实现代码】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)
发表我的评论

最新评论

  1. 暂无评论