日期:2014-05-17  浏览次数:20396 次

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返回

        });
       
    });



<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>

jQuery?Ajax jQuery HTML

------解决方案--------------------
for循环 json
拼接成html 然后塞给div

不会就学~ 1~3天的事情