参数以'null'使用Jquery时调用ajax绑定网格数据
Parametres passing as 'null' when using Jquery Grid ajax call for binding grid data
我有一个Jquery网格,我使用ajax调用绑定到控制器。在ajax调用期间,控制器方法被击中,但是参数值作为null传递给控制器方法。
在ajax属性'data:'
这是我的JavaScript代码:
function BindGridData()
{
var BUids=$("#ddlBU").val().join(",");
var Zoneids=$("#ddlZone").val().join(",");
var Regionsids=$("#ddlRegion").val().join(",");
var Territoryids=$("#ddlTerritory").val().join(",");
$("#tblJQGrid").jqGrid(
{url: "@Url.Action("GetGeographyBreakUpData", "GeoMap")",
datatype: "json",
data: "{BUIds :'" + BUids + "',ZoneIds:'"+Zoneids+"',RegionIds:'"+Regionsids+"',TerritoryIds:'"+Territoryids+"'}",
mtype: 'GET',
colNames: ['Id','GeoGraphy', 'Completed', 'InProgress'],
colModel: [
{ name: 'Id', index: 'Id', width: 20, stype: 'text',hidden:true },
{ name: 'Geography', index: 'Geography', width: 150 },
{ name: 'Completed', index: 'Completed', width: 150 },
{ name: 'InProgress', index: 'InProgress', width: 150 },
],rowNum: 10,
sortname: 'Id',
viewrecords: true,
sortorder: "desc",
caption: "Geographical Survey Status",
scrollOffset: 0});
var res=$('#ddlResponseType').val();
res=res.join(',');
if(res=='1')
{
$("#tblJQGrid").hideCol("Completed");
}
else if(res == '2')
{
$("#tblJQGrid").hideCol("InProgress");
}
else
{
$("#tblJQGrid").showCol("InProgress");
$("#tblJQGrid").showCol("Completed");
}
}
这是我的控制器方法
public string GetGeographyBreakUpData(string BUIds, string ZoneIds, string RegionIds, string TerritoryIds, string MarketIds, string FOIds, string ResponseTypeIds, string FromDate, string ToDate, string GridBreakUpLevel)
{
}
谁能告诉我我的代码错在哪里?
我试图使用Params
数组发送值,即使这样,Params
数组也作为null
下面是更新后的代码
var BUids=$("#ddlBU").val();
var Zoneids=$("#ddlZone").val();
var Regionsids=$("#ddlRegion").val();
var Territoryids=$("#ddlTerritory").val();
Params = new Array();
Params.push(BUids);
Params.push(Zoneids);
Params.push(Regionsids);
Params.push(Territoryids);
Params = Params.join("|");
$("#tblJQGrid").jqGrid(
{url: "@Url.Action("GetGeographyBreakUpData", "GeoMap")",
datatype: "json",
data: { "Parameters": Params },
mtype: 'GET',
colNames: ['Id','GeoGraphy', 'Completed', 'InProgress'],
colModel: [
{ name: 'Id', index: 'Id', width: 20, stype: 'text',hidden:true },
{ name: 'Geography', index: 'Geography', width: 150 },
{ name: 'Completed', index: 'Completed', width: 150 },
{ name: 'InProgress', index: 'InProgress', width: 150 },
],rowNum: 10,
sortname: 'Id',
viewrecords: true,
sortorder: "desc",
caption: "Geographical Survey Status",
scrollOffset: 0});
控制器public string GetGeographyBreakUpData(string Parameters)
{
}
据我所知,由于datatype: json
, data
属性无法形成查询字符串参数。不是因为它是不正确的,但它可能转换为content-type "application/x-www-form-urlencoded"
我怀疑processData属性可能是失败的原因。我还没有尝试过实际支持这个问题,我愿意让人们编辑这个答案,如果他们发现其他的。
对于这个问题,我们用传统的方式设置参数
url: "@Url.Action("GetGeographyBreakUpData", "GeoMap")"+"?BUIds='"+ BUids + "'&ZoneIds='"+Zoneids+"'&RegionIds='"+Regionsids+"'&TerritoryIds='"+Territoryids+"'"
如果我发现更多的我会更新这个。只是想分享这个jQuery.param()
相关文章:
- 如何将事件绑定到从AJAX请求注入的HTML
- 如何在AJAX驱动的应用程序中优化元素绑定
- jQuery Ajax 元素的后期绑定不起作用
- 使用ajax/jquery绑定Json数据
- 将类方法绑定到类外绑定的事件处理程序内的AJAX成功回调
- AJAX请求导致更改函数解除绑定
- 如何在ajax请求周期性自动刷新时使用knockout.js数据绑定
- 结构化和绑定(ajax响应)
- 当通过Ajax成功回调更新可观察数组时,启用绑定中断
- 在表单提交将DOM的一部分替换为分部之后,我应该将ajax成功绑定到什么来使我的javascript工作
- jQuery绑定了没有DOM元素的AJAX事件
- 将函数绑定到Twitter Bootstrap Modal Ajax Complete
- 重新绑定分配给ajax链接的操作
- 从ajax中为传递为null的日期值绑定模型
- 使用AJAX发布数据,同时使用淘汰绑定
- 如何将 jquery ajax 绑定到父级
- 当通过AJAX绑定选项时,是否可以将select元素的默认值传递给Knockout
- 参数以'null'使用Jquery时调用ajax绑定网格数据
- 在knockout中通过ajax绑定select
- 如何在Ajax绑定的Telerik MVC网格上持久化分组设置