0
我阿贾克斯块看起来像这样:JSON结果从MVC使用Ajax没有显示
$('#btnTest').click(function(){
$.getJSON('/User/ViewMessages',function(result) {
// TODO: update the DOM with the items
$("table#tblMessages").append("<tr><td>"+result.MESSAGETEXT+"</td><td>"+result.DATESENT+"</td>");
});
});
我在我的控制器动作看起来像这样:
public ActionResult ViewMessages()
{
var recipient = Convert.ToInt32(HttpContext.Session["User_Id"]);
var query = (from m in context.Messages
from rec in context.Recipients
where rec.RECIPIENT == recipient
where rec.MESSAGEID == m.MESSAGEID
select new
{
m.MESSAGETEXT,
m.DATESENT
}).ToList();
return Json(query.ToList());
}
调试时,我的查询变量的回报: {MESSAGETEXT =“seresr”,DATESENT = {2011年9月15日11时06分45秒}}
事情是,我的表是添加“undefined”为我的价值观。我哪里出错了?我已经添加了maproute,但我仍然运气不佳。
/捂脸时刻,谢谢你。 –