使用ajax在display标签中加载json数据



JQuery

 jQuery.noConflict();
    jQuery(document).ready(function(){
        jQuery("#stallId").change(function(e){
            //prevent default action
            e.preventDefault();
            jQuery.ajax({
                url: "getProducts.html?method=Product&stallId="+document.getElementById("stallId").value,
                dataType: "json",
                success: function(json){
                    if(json.status == true){
                        var strHtml='';
                        strHtml=+"";                  
                        for(var i=0;i<json.promotionProductList.length;i++){
                        }
                    }                   
                },
                failure: function(){
                    alert( "FAILED" );
                }
            });
        });
    });

显示标签

 <display:table name="ProductList" id="product" class="table" export="false">
    <display:column escapeXml="true" titleKey="productForm.name">
    </display:column>
</display:table>

行动类

Map productMap = new HashMap();
productMap.put("id", "1");
productMap.put("name", "Coca Cola");                
List<Product> productList = new ArrayList<Product>();
productList.add(productMap);
jsonWriter.object()
    .key("status").value(true)                   
    .key("pList").value(productList)
    .endObject();

如何使用ajax在display标签中加载json数据?当我从dropdownlist中选择一个摊位时,它会将url发送到后端操作类,并能够获得产品地图的列表,但我不知道如何使数据显示在display标签中。有人能帮我,告诉我如何加载数据吗?顺便说一句,我用的是支柱1。

在我使用firebug检查显示标签部分后,我发现显示标签将更改为普通的html表。所以在ajax中:

success: function(json){
    if(json.status == true){
        var strHtml='';                
        for(var i=0;i<json.pList.length;i++){
        strHtml+='<tr><td>'"+json.pList[i].name+"'</td></tr>';  
        }
    jQuery("table#product tbody").html(strHtml);
    }                   
},

在jQuery("表#产品tbody")中,"表"是指显示表标签,#product指的是显示表id。

最新更新