This time I bring you jQueryDynamic implementation of ajaxFile download, what are the precautions for jQuery to dynamically implement ajax file download, the following is a practical case , let’s take a look.
// Ajax 文件下载 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(); }; };
***That is, dynamically rendering the form, and then delete after submitting the form. ***
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Jquery LigerUI detailed explanation of file upload steps
jquery dynamically loaded js file detailed explanation
Detailed explanation of the steps to asynchronously upload files using the PHP jQuery plug-in
The above is the detailed content of jQuery dynamically implements ajax file download. For more information, please follow other related articles on the PHP Chinese website!