【发布时间】:2013-05-15 11:20:07
【问题描述】:
在没有被调用的情况下回调。
function GetTrainingResults(id,callback){
$.getJSON("/dashboard/GetTrainingResults/", {'id':id}, callback);
}
GetTrainingResults('id',function(result){
alert(result);
});
后面的代码是
public ActionResult GetTrainingResults(int id)
{
string test = "You are there.";
return Json(test, JsonRequestBehavior.AllowGet);
}
或者建议和其他方式。调用控制器方法并等待javascript中的方法响应的任务。
谢谢
【问题讨论】:
-
当前代码成功触发了代码行为,但没有调用回调函数。
-
使用完整的 .ajax 函数来查看它是否命中错误而不是成功。有关详细信息,请参阅下面的答案。
标签: c# javascript jquery asp.net-mvc