问题描述
我正在设计一个基于 ASP.NET MVC 的 SPA。其他部分工作正常,但是以下给出了 504 错误。我在 JavaScript 中添加了警报以查看它的进展情况。有时甚至在调用控制器中的函数之前我得到 504,有时在控制器返回值后收到 504。
型号:
public class CountryModel
{
public List<Stat> Stats { get; set; }
}
public class Stat
{
public string Description { get; set; }
public string Key { get; set; }
public string Value { get; set; }
public Int64 Count { get; set; }
}
控制器:
public JsonResult GetStats(string code )
{
//Code will be used for other calculations.
List<Stat> tStat = new List<Stat>();
Stat stat = new Stat();
stat.Key = "AAA";
stat.Value = "1000";
stat.Count = 111;
tStat.Add(stat);
stat = new Stat();
stat.Key = "BBB";
stat.Value = "2000";
tStat.Add(stat);
stat = new Stat();
stat.Key = "CCC";
stat.Value = "3000";
tStat.Add(stat);
var stats = tStat;
return Json(stats);
}
查看:
@model MvcApplicationrazor.Models.CountryModel
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h4>
My SPA.
</h4>
@using (Html.BeginForm())
{
<input type="submit" value="Search" onclick="javascript:Search('myCode');" />
<br />
<br />
}
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script language="javascript" type="text/javascript">
function Search(_code) {
alert("A1");
var url = "/Home/GetStats/";
$.ajax({
url: url,data: { code: _code },type: "POST",success: function (stats) {
alert("Success-1");
......
alert("Success-3");
},error: function (reponse) {
alert("error : " + reponse.responseXML);
}
});
}
</script>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)