控制器
public JsonResult TeamInfo(string teamName)
{
teamDA = new TeamDataAccess();
var teamInfo = teamDA.TeamInfo(teamName);
System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(teamInfo);
JsonResult jsonResult
=new JsonResult(){ JsonRequestBehavior = JsonRequestBehavior.AllowGet };
jsonResult.Data = sJSON; // first i give this.
jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
return jsonResult;
}
从 jQuery 调用控制器
$.ajax({
url: 'Team/TeamInfo/' + teamName,
success: function (data) {
$('#teamDetails').html(data);
alert('Load was performed.');
$("#dialog-modal").dialog("open");
}
});
在调试时,我可以看到它一直执行到控制器的最后一行return jsonResult;
但alert('Load was performed.');
不可见。你知道它没有进入成功部分的原因是什么吗?服务器端没有错误。非常感谢任何帮助。
编辑
当我添加error
in ajax 调用时。它显示错误 500(内部服务器错误)。我如何找到这个问题?