Home >Web Front-end >JS Tutorial >jQuery uses dynamic rendering form function to complete ajax file download_jquery

jQuery uses dynamic rendering form function to complete ajax file download_jquery

WBOY
WBOYOriginal
2016-05-16 17:43:381124browse
Copy code The code is as follows:

// Ajax file download
jQuery.download = function(url , data, method){
// Get url and data
if( url && data ){
// data is string or array/object
data = typeof data == 'string' ? data : jQuery.param(data);
// Assemble parameters into form input
var inputs = '';
jQuery.each(data.split('&'), function(){
var pair = this.split('=');
inputs ='';
});
// request to send a request
jQuery('
' inputs '
')
.appendTo('body').submit().remove();
};
};

** *That is, the form is dynamically rendered and deleted after the form is submitted. ***

Call instance
Copy code The code is as follows:

$.download('ExcelDownload.do','find=commoncode','post' );
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn