/*===================Download file
* options:{
* url:'', //Download Url
* data:{name:value}, //the datas you want to post
* method:'post'
* }
*/
var DownLoadFile = function (options) {
var config = $.extend(true, { method: 'post' }, options);
var $iframe = $('<iframe id="down-file-iframe" /&>');
var $form = $('<form target="down-file-iframe" method="' + config.method + '" /&>');
$form.attr('action', config.url);
for (var key in config.data) {
$form.append('<input type="hidden" name="' + key + '" value="' + config.data[key] + '" /&>');
}
$iframe.append($form);
$(document.body).append($iframe);
$form[0].submit();
$iframe.remove();
}
Read More:
- If the request parameter is formdata, use the Ajax operation
- SwiftUI 2.0: How to Import Files into iOS Apps
- How to open a page in a new window by Vue router
- Difference between contenttype and datatype in Ajax request of jquery
- [Solved] it only responds to error and does not enter success after AJAX is successfully processed
- The solution that needs alert to execute after using ajax
- How to Solve Files Upload Error: http://net::ERR_SSL_PROTOCOL_ERROR
- [Solved] ajax Error: Uncaught SyntaxError: Unexpected end of JSON input
- [Solved] IE Browser Error: unhandled promise rejection error: access is denied. File stream Download
- The solution of calling$. Ajax successfully but the success method does not respond
- Vue-cli Failed to download repo vuejs-templates/webpack [How to Solve]
- How to Fix “HTTP 405 method not allowed” Error
- [Solved] node.js Upload Files Error: Multipart: boundary not found multer
- Vue: How to Fix “not displaying the holder in IE9 and below”
- [Solved] Error:Plugin/Preset files are not allowed to export objects, only functions
- Solution to some map files in JS folder after Vue packaging (remove the map. JS file)
- Using ts-node to Execute .ts files Error [Solved]
- Vue2.0: How to Use vue3 api to encapsulate Axios
- CSS to achieve dynamic display of picture text by mouse touch