标签:param www lang request action required query str value
ajax 文件下载,实际上就是模拟表单提交,代码如下:
function download(url, data, method){
//url and data options required
if( url && data ){
//data can be string of parameters or array/object
data =typeof data ==‘string‘? data : jQuery.param(data);
//split params into form inputs
var inputs =‘‘;
jQuery.each(data.split(‘&‘), function(){
var pair =this.split(‘=‘);
inputs+=‘<input type="hidden" name="‘+ pair[0]+‘" value="‘+ pair[1]+‘" />‘;
});
//send request
jQuery(‘<form action="‘+ url +‘" method="‘+(method||‘post‘)+‘">‘+inputs+‘</form>‘)
.appendTo(‘body‘).submit().remove();
};
};
标签:param www lang request action required query str value
原文地址:http://www.cnblogs.com/rongfengliang/p/6690821.html