动态提交使用jQuery 完成ajax 文件下载
https://my.oschina.net/u/1409620/blog/323734
jQuery.download = function(url, data, method){ //获得url和data if( url && data ){ //data 是 string 或者 array/object data = typeof data == 'string' ? data : jQuery.param(data); //把参数组装成form的input var inputs = ''; jQuery.each(data.split('&'), function(){ var pair = this.split('='); inputs+='<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />'; }); //request发送请求 jQuery('<form action="'+ url +'" method="'+ (method||'post') +'">'+inputs+'</form>').appendTo('body').submit().remove(); }; };
调用实例:
$.download('ExcelDownload.do','find=commoncode','post');
相关推荐
TONIYH 2020-07-22
83510998 2020-07-18
wcqwcq 2020-06-26
delmarks 2020-06-14
ppsurcao 2020-06-14
tthappyer 2020-06-07
delmarks 2020-06-28
89510194 2020-06-27
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11