艾米, 我有同樣的問題。 我不是一個程序員(你會意識到通過代碼我會粘貼在這裏:))但我找到的解決方案似乎工作正常。
這是我對另一個類似問題(與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