如何在jquery中绑定datalist

我想在jquery中绑定我的datalist。 这是我的客户端代码:

   $(function () { $.ajax({ type: "POST", url: "WebForm1.aspx/GetProducts", data: '{}', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { alert(response.d); }, error: function (response) { alert(response.d); } }); }); function OnSuccess(response) { $("[id*=dlOnFrontPageProducts]").attr("border", "1"); var xmlDoc = $.parseXML(response.d); var xml = $(xmlDoc); var customers = xml.find("Table1"); var row = $("[id*=dlOnFrontPageProducts] tr:last-child").clone(true); $("[id*=dlOnFrontPageProducts] tr:last-child").remove(); $.each(customers, function () { alert(this); var customer = $(this); $(".Name", row).html(customer.find("Name").text()); $(".BrandName", row).html(customer.find("BrandName").text()); $(".MarketPrice", row).html(customer.find("MarketPrice").text()); $(".CurrencyShortName", row).html(customer.find("CurrencyShortName").text()); $(".Price", row).html(customer.find("Price").text()); $(".WindowImageUrl", row).html(customer.find("WindowImageUrl").text()); $(".SaleCount", row).html(customer.find("SaleCount").text()); $(".IsActive", row).html(customer.find("IsActive").text()); $("[id*=dlOnFrontPageProducts]").append(row); row = $("[id*=dlOnFrontPageProducts] tr:last-child").clone(true); }); }      
<a class="wrap_link" href="https://stackoverflow.com/questions/12677249/how-to-bind-datalist-in-jquery/ProductDetail.aspx?prid=">

<a class="add_to_cart_small" href="https://stackoverflow.com/core/ajaxresult.aspx?act=prod&prid="> Sepete Ekle Listeme Ekle Karşılaştır

我返回的数据是正确的,但datalist没有绑定。 你有什么建议吗?

这是我的代码请检查您的代码并进行适当的更改并获得答案

Asp.Net代码:

    
<%# Eval("PlotNumber") %>
Seasoncode:<%# Eval("Seasoncode") %>
Village: <%# Eval("Village") %>
Planting Date: <%# Eval("PlantingDate")%>
Plant: <%# Eval("Planttype")%>    Crop: <%# Eval("CropType")%>    Nursery: <%# Eval("NurseryType")%>
Cutas Setts: <%# Eval("CutasSetts")%>
Seed Supply: <%# Eval("SeedSupply")%>
Cutas Bulk: <%# Eval("CutasBulk")%>
Cane Supply: <%# Eval("CaneSupply")%>

Jquery代码: –


 function plot_details(paramstr) { $("[id*=dlCustomers]").hide(); $.ajax({ type: "POST", url: "CommonView.aspx/GetCustomers", data: "{'paramstr': '" + paramstr + "', 'procname': '" + 'DBSP_Get_PartyPlotView' + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { alert(response.d); }, error: function (response) { alert(response.d); } }); } function OnSuccess(response) { var xmlDoc = $.parseXML(response.d); var xml = $(xmlDoc); var customers = xml.find("Table"); var repeatColumns = parseInt("<%=dlCustomers.RepeatColumns == 0 ? 1 : dlCustomers.RepeatColumns %>"); var rowCount = Math.ceil(customers.length / repeatColumns); var i = 0; while (i < repeatColumns * rowCount) { var row = $("[id*=dlCustomers] tr").eq(0).clone(true); for (var j = 0; j < repeatColumns; j++) { var customer = $(customers[i]); if (customer.length == 0) { $("table:last", row).remove(); } else { $(".plot", row).eq(j).html(customer.find("PlotNumber").text()); $(".Season", row).eq(j).html(customer.find("Seasoncode").text()); $(".Village", row).eq(j).html(customer.find("Village").text()); $(".PlantingDate", row).eq(j).html(customer.find("PlantingDate").text()); $(".Planttype", row).eq(j).html(customer.find("Planttype").text()); $(".CropType", row).eq(j).html(customer.find("CropType").text()); $(".NurseryType", row).eq(j).html(customer.find("NurseryType").text()); $(".Variety", row).eq(j).html(customer.find("Variety").text()); $(".CutasSetts", row).eq(j).html(customer.find("CutasSetts").text()); $(".CutasBulk", row).eq(j).html(customer.find("CutasBulk").text()); $(".SeedSupply", row).eq(j).html(customer.find("SeedSupply").text()); $(".CaneSupply", row).eq(j).html(customer.find("CaneSupply").text()); } i++; } $("[id*=dlCustomers]").append(row); } $("[id*=dlCustomers] tr").eq(0).remove(); $("[id*=dlCustomers]").show(); }