我写了这段代码,但没有得到我想要的结果。请帮帮我
javascript代码
$.ajax({
type: "POST",
url: "userControls/Wsc_comn.asmx/BindCategory",
data: "{}",
dataType: "json",
contentType: "application/json; charset=utf-8",
async: true,
success: OnSuccess,
error: OnError
});
function OnSuccess(data) {
$.each(data, function(key, value) {
$("#tablet").append("<li><a rel='external' href='" + this.attachment_url + "'>" + value.Product_name + "</li>");
});
}
function OnError(data) {
}
c#code
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string BindCategory()
{
string qry = "select *from products where Product_type='TABLETS'";
DataTable dt = dllmain.ExecuteselectQry_returns_datatable(qry);
foreach (DataRow row in dt.Rows)
{
string urls = row["attachment_url"].ToString();
string catname = row["Product_name"].ToString();
}
return dllgetinfo.getdatatabletojson(dt);
}