艾米, 我有同样的问题。 我不是一个程序员(你会意识到通过代码我会粘贴在这里:))但我找到的解决方案似乎工作正常。
这是我对另一个类似问题(与jqGrid无关)的解决方案。
excelExport : function(o) {
o = $.extend({
exptype : "remote",
url : null,
oper: "oper",
tag: "excel",
exportOptions : {}
}, o || {});
return this.each(function(){
if(!this.grid) { return;}
if(o.exptype == "remote") {
var pdata = $.extend({},this.p.postData);
pdata[o.oper] = o.tag;
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", o.url);
form.setAttribute("target", "_blank");
$.each(pdata, function(i, l){
if (typeof l != 'undefined') {
if (typeof l == 'function') {
post_value = l();
}
else {
post_value = l;
}
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", i);
hiddenField.setAttribute("value", post_value);
form.appendChild(hiddenField);
}
});
document.body.appendChild(form); // Not entirely sure if this is necessary
form.submit();
}
});
}
正如您所看到的,它会创建一个表单并将数据发布到新页面。 这里的大多数人会发现一个更好(更优雅)的方式来做到这一点,但这个解决方案,就像是,工作。 我需要向服务器发送大量信息,所以GET对我来说不够用,这就是为什么我需要POST数据。
希望这对你有用。
JMG。
来源
2012-04-11 19:42:42
JMG
如果您计划奖励赏金,您应该明确地做到这一点(请参阅“如何奖励赏金?”[详细信息](http://meta.stackoverflow.com/privileges/set-bounties) – Oleg 2011-04-26 12:04:33
谢谢Oleg。当我接受答案时,我曾假设它被授予。 – 2011-04-26 12:19:26
不客气!我了解你,正因为如此,我发布了你的参考资料,描述奖赏真正如何工作。 – Oleg 2011-04-26 12:24:03