从MVC加载数据Jtable时出错
Error load data Jtable from MVC?
我在codeproject.com/script/Articles/ArticleVersion.aspx上读到了这篇关于jtable with mvc的文章?aid=277576&av=419297
我试过了。但当运行时,我得到错误An error occured while communicating to the server.
请查看我的代码。控制器内
[HttpPost]
public JsonResult LocalList(int jtStartIndex, int jtPageSize, string jtSorting)
{
try
{
string localCount = db.Database.SqlQuery<string>("Select Count(*) FROM Location").ToString();
IEnumerable<LOCATION> query = db.LOCATIONs;
if (jtSorting.Equals("LOCATION_ID ASC"))
{
query = db.LOCATIONs.OrderBy(e => e.LOCATION_ID).Skip(jtStartIndex).Take(jtPageSize).ToList();
}
else
{
query = db.LOCATIONs.OrderBy(e => e.LOCATION_ID).Skip(jtStartIndex).Take(jtPageSize).ToList();
}
return Json(new { Result = "OK", Records = query, TotalRecordCount = int.Parse(localCount) });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
在视图中
$('#div_local').jtable({
title: 'List Location',
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
defaultSorting: 'LOCATION_ID ASC', //Set default sorting
actions: {
listAction: 'HomeController/LocalList'
},
fields: {
AREA_ID: {
key: false,
list: false,
create: false
},
LOCATION_ID: {
key: true,
list: false,
create: false
},
LOCATION_NAME: {
title: 'Name'
},
LOCATION_DES: {
title: 'Des'
}
}
});
$('#div_local').jtable('load');
在这里,所有的文件脚本和样式表都可以
Request URL:http://localhost:27508/HomeController/LocalList?jtStartIndex=0&jtPageSize=10&jtSorting=LOCATION_ID%20ASC
Request Method:POST
Status Code:404 Not Found
你能告诉我这里发生了什么错误吗?以及如何修复。谢谢大家。
看起来listAction指向了一个不存在的url(由于HTTP错误404)。
你能使用你在日志中找到的请求url手动下载json吗?
我创建了如下
1) 删除[HttpPost]
2) 编辑列表操作listAction: 'Home/LocalList'
工作不错。
相关文章:
- javascript中的数组出错
- 节点Js:How to catch a“;没有这样的文件或目录“;读取线模块出错
- 在Meteor项目中安装并包含npm模块后出错
- 解析JSON并从中删除对象会出错
- AngularJS指令出错-无法读取属性'编译'的未定义
- 使用javascript在MVC中查找网格长度时出错
- 尝试调用AngularJS上的函数时出错
- Google 脚本:用于创建日历活动的脚本运行时不会出错,但不会执行任何操作
- 全局安装gull后出错
- 我在代码点火器中出错
- Java脚本将URL转换为已保存的URL时出错
- Backbone.js将模型绑定到视图时出错
- 将javascript代码转换为jquery代码时出错
- 加载db.json时出错
- 在运行时创建元素时移到一边时出错
- 失败:等待Protractor与页面同步时出错:“”;在窗口上找不到角度”;
- 重置表单字段时出错
- 将对象的列表c#传递给javascript:undefined变量时出错
- 地理定位api和谷歌地图出错
- 从MVC加载数据Jtable时出错