jQuery-Iframe-Transport 是一款基于 iframe 文件上传的 jQuery Ajax 传输插件,通过隐藏的 iframe 来实现传输。
要使用这个插件,只需简单的添加一个值为 true 的 iframe 选项到设置了 $.ajax() 调用的 Ajax 中,然后使用 files 选项指定要包含在子控件中的文件字段,该选项可以是选择器、jQuery 对象或包含一个或多个 <input type="file"> 元素的 DOM 列表:
$("#myform").submit(function() {
$.ajax(this.action, {
files: $(":file", this),
iframe: true
}).complete(function(data) {
console.log(data);
});
});
该插件将构造隐藏的 <iframe> 和 <form> 元素,然后将文件字段添加到该表单,并提交表单处理响应。
官方文档:https://cmlenz.github.io/jquery-iframe-transport/
Gitee 地址 :https://gitee.com/mirrors/jQuery-Iframe-Transport