0
我有以下ajax jQuery代碼,在document.ready函數從ajaxFileDownload.php下載文件。表單上的jQuery和Ajax提交 - 解析POST數據
但是,我想用它代替document.ready
函數用於提交一個稱爲報表的表單。所以,當我點擊提交表單名稱報告,然後運行這個,我也想解析表單字段發佈變量稱爲user_id
到php文件。
任何想法如何做到這一點?
我說:$('#reports').on('submit', function(e) {
我怎樣才能添加USER_ID職位變量?
$(function() {
$('#reports').on('submit', function(e) {
var $preparingFileModal = $("#preparing-file-modal");
$preparingFileModal.dialog({
modal: true
});
$.fileDownload('ajaxFileDownloader.php?' + Math.random(), {
successCallback: function (url) {
$preparingFileModal.dialog('close');
},
failCallback: function (responseHtml, url) {
$preparingFileModal.dialog('close');
$("#error-modal").dialog({
modal: true
});
}
});
return false; //this is critical to stop the click event which will trigger a normal file download!
});
});
你打算從哪裏得到'user_id'?你還讀過關於數據''jQuery.Ajax()'](http://api.jquery.com/jQuery.ajax/)? – kero
@kingkero我打算從相同的報告表單獲取user_id,有一個隱藏的字段,其值爲user_id – John