我只是认为这是从数据库中获取数据的变量 我在单独的类
中声明了Description属性public class Description
{
public int DesID{set;get;}
public string Description{
}
C#编码:数据
[WebMethod]
public static List<Description> Data()
{
List<Description> listDescription = new List<Description>();
Description d1=new Description()
{
DesID=1,
Description ="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
};
Description d2=new Description()
{
DesID=2,
Description ="thanks for your response"
};
listDescription.add(d1);
listDescription.add(d2);
}
JSON:
$(document).ready(function () {
$(function () {
$.ajax({
contentType: 'application/json; charset=utf-8',
url: 'WebForm1.aspx/Data',
dataType: 'json',
method: 'post',
success: function (data) {
for (var i = 0; i < data.d.length; i++) {
$('#divdisplay').append("<div>Description ID : "+ data.d[i].DesID+"<br/>Description : "+data.d[i].Description+</div>");
}
},
error: function (result) {
alert('Error');
}
});
});
我已经尝试过以下代码,但它无效
$(data.d[i].Description).val().substr(1,5); And
data.d[i].Description.val().substr(1,5)
$(data.d[i].Description).val().substring(1,5); And
data.d[i].Description.val().substr