问题描述
我无法在 firebug 中看到任何传递给服务器的参数值.这是代码.
I'm not able to see any parameters value passing to server in firebug. Here is the code.
//BuyBackGridInit() start
function BuyBackGridInit(tabID){
$('table[id$="'+tabID+'_BuyBackGrid"]').jqGrid({
url :'/Controls/Advertiser/BuyBackControlNew.ascx.ashx?action=getBuyBackData',
datatype: 'json',
mtype: 'POST',
height:'100%',
width:'100%',
colNames: result.colNamesData,
colModel: result.colModelData,
postData: {
advertiserID: function() { return $('#advertiser_id').text(); },
CampaignsDdlSelectedValue: function() { return $('select[id$="CampaignDdl"] option:selected').val(); },
startDate: function() { return $('input[id$="'+tabID+'_FromCalBuyBack_CalendarTbx"] ').val(); },
endDate: function() { return $('input[id$="'+tabID+'_ToCalBuyBack_CalendarTbx"] ').val(); }
},
rowNum : 100,
shrinkToFit :false,
altRows: true,
altclass:'altRow',
autowidth: true,
multiselect: true,
gridComplete:function (){
var recs = parseInt( $('table[id$="'+tabID+'_BuyBackGrid"]').getGridParam("records"),10);
if (recs == 0){
$('div[id$="'+tabID+'_NoDataFoundBuyBackdiv"]').show();
$('input[id$="AddToCartBtn"]').hide();
$('input[id$="BuyBackDownloadBtn"]').hide();
}
else {
$('div[id$="'+tabID+'_NoDataFoundBuyBackdiv"]').hide();
$('input[id$="AddToCartBtn"]').show();
$('input[id$="BuyBackDownloadBtn"]').show();
}
},
serializeGridData: function (data){
return $.toJSON(data);
}
});//end of jQuery("#BuyBackGrid").jqGrid()
}//BuyBackGridInit() End
谢谢,
一个
推荐答案
你当前的 serializeGridData
实现只是 remove 从 postData
.因此,您应该在 serializeGridData
内扩展 data
参数,而不是使用 postData
.另一种方法是将 serializeGridData
修改为以下内容:
You current implementation of serializeGridData
just remove all functions parameters from the postData
. So you should either extend data
parameter inside of serializeGridData
instead of the usage of postData
. Another way is to modify serializeGridData
to the following:
serializeGridData: function (data){
var propertyName, propertyValue, dataToSend = {};
for (propertyName in data) {
if (data.hasOwnProperty(propertyName)) {
propertyValue = data[propertyName];
if ($.isFunction(propertyValue)) {
dataToSend[propertyName] = propertyValue();
} else {
dataToSend[propertyName] = propertyValue
}
}
}
return JSON.stringify(dataToSend);
}
在上面的代码中,我们枚举了所有属性并显式调用了所有函数.此外,我更喜欢使用 json2.js 中的 JSON.stringify
函数.该功能将在许多网络浏览器中原生实现.
In the code above we enumerate all properties and call all functions explicitly. Moreover I prefer to use JSON.stringify
function from json2.js. The function will be native implemented in many web browsers.
查看演示这里.
这篇关于postData 没有传递任何参数!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!