首页 新闻 会员 周边

ajax获取后台数据

0
悬赏园豆:10 [已解决问题] 解决于 2013-07-23 10:37

用ajax获取后台数据库中的数据,要怎么写呢?后台是用asp写的,请举个例子

小菜刚的主页 小菜刚 | 初学一级 | 园豆:74
提问于:2013-07-19 20:01
< >
分享
最佳答案
0

$.ajax({
type: "POST",// Post 请求
data: { 'page': _page, 'id': id, "ccid": ccid },//需要传的参数
url: "/Web/AjaxLoadArticleMore",// 后台的方法
dataType: "json",// 采用json ,
success: function (info) {
if (info.length > 0) {
 
 
var _tmp_html = '';
$.each(info, function (x, y) { 

alert(y.id);//弹出ID

});

 
 
} else {
alert("没有数据");
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
lert(errorThrown);//出错啦!
}
});

收获园豆:10
web王 | 菜鸟二级 |园豆:225 | 2013-07-21 23:48
其他回答(1)
0

PersonsDataContext db = new PersonsDataContext();
var res = new PersonsDataContext().persons.ToList();
var rs = from m in res
select new Person
{
id = m.id,
name = m.name,
classid = m.classid == null ? 0 : m.classid.Value,
classname = m.classinfo == null ? "" : m.classinfo.classname,
email = m.email,
sex = m.sex,

};
return rs;
}

真假不分 | 园豆:248 (菜鸟二级) | 2013-07-20 14:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册