jquery ajax 给div内内容赋值,求教,对jquery不是很熟悉
$(document).ready(function () {
alert("adasd"); $.ajax({
type: "POST",
url: "index.ashx", //调用的url
dataType: 'json', //返回Json类型
success: function (data) {
$.each(data, function (i, loan) {
$("#test").html(loan.productName);
//我要讲json的值,给div内的元素赋值
}
);
} //回调函数,data返回
});
});
jQuery?Ajax jQuery HTML
<div class="conn" id="test">
<img src="images/pic-index-3.jpg">
<h2><a href="#">。。。</a></h2>
<span><font>。。。</font>。。。。</span>
<a href="#" class="cp"><img src="images/pic-index-7.jpg"></a>
</div>
<div class="conn">
<img src="images/pic-index-4.jpg">
<h2><a href="#">。。。</a></h2>
<span><font>。。。</font>。。。</span>
<a href="#" class="cp"><img src="images/pic-index-7.jpg"></a>
</div>