- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我正在编写一个允许我异步上传图像的小 JavaScript 应用程序。
这个脚本在每个浏览器中都很棒,除了 Internet Explorer...
所以我做的第一件事是使用 AjaxForm Plugin for jQuery 创建 IE9 版本的回退,效果很好!
这是 JS 脚本。
$("#Uploader").change(function(e){
var form = $("#UploaderForm");
form.trigger('submit');
$(this).attr('disabled','disabled');
e.preventDefault();
});
$("#UploaderForm").submit(function(e){
e.preventDefault();
e.stopPropagation();
var type="POST";var loading=$("#PhotoIsLoading");
if(windowApi === true){
var formData = new FormData($(this)[0]);
$.ajax({
url: url,
type: type,
xhr: function() {
myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ myXhr.upload.addEventListener('progress',progressHandlingFunction, false);}
return myXhr;
},
beforeSend: function(){loading.removeClass('isHidden_important');},
success: function(response){
jres = JSON.parse(response);
alert("Test ok, file uploaded");
},
error: function(response){console.warn(response);},
data: formData,
cache: false,
contentType: false,
processData: false
});
e.preventDefault();
}else{
$(this).ajaxSubmit({
url: url,
dataType: 'json',
type: type,
beforeSubmit: function(){loading.removeClass('isHidden_important');$(this).formSerialize();},
success:function(response){
jres = JSON.parse(response);
alert("FallbackTest Complete");
},
error: function(response){console.warn(response);},
});
e.preventDefault();
return false;
}
});
WindowApi
和所有其他变量都在全局脚本中定义,但不用担心,它们可以工作。准确地说,WindowApi
是这样的:
var windowApi=true;
if(window.File&&window.FileReader&&window.FileList&&window.Blob){
console.log("window.api ready");windowApi=true;}
else{console.log("window.api not ready");windowApi=false;};
所以,通过这一堆代码,我可以处理所有浏览器和 IE9- 浏览器...
现在的问题是 IE10,因为它拥有所有 window.*
方法,并且可以使用 FormData
对象。但是,当我尝试使用 IE10 和 FormData 上传内容时,我收到 formData 对象的“访问被拒绝”错误。
此过程中涉及的 HTML 是:
<form name="UploaderForm" id="UploaderForm" method="post" enctype="multipart/form-data">
<input type="file" name="Uploader" id="Uploader" accept="image/*" tabindex="1" />
</form>
最后我的问题是:
如何避免在 IE10 中尝试访问 FormData 对象时出现“拒绝访问”异常?
最佳答案
https://stackoverflow.com/a/13657047/641293和 https://stackoverflow.com/a/4335390/641293可能有用。 IE 对你可以用 <input type='file'>
做什么非常严格以编程方式。
基于第一个,将第一行更改为此是否可以解决问题?
$("#Uploader").on('click', function(e){ /* rest of the function unchanged... */
关于javascript - FormData 对象在 Internet Explorer 10 中可用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14316240/
我有以下代码,使用ajax上传文件,因为我不想使用表单操作。但我无法这样做。代码是: Select xml file to upload: ajax代码是: $('#upload_xml').on
我有 3 个图像或多图像数组,其总大小约为。 29mb 或以上。我尝试使用 Ajax 和表单数据将其发布在服务器端。但是当我尝试在 MVC 中使用 FormData 发布大数据时它显示错误,有什么解决
我想了解浏览器如何解释表单数据。我知道一个 http 请求包含 [Method][Header][URL][Params][Body] 我不知道如何将表单数据放在那里?它是被解释为参数(查询字符串)还
我正在做一个项目,我需要在提交之前更改 FormData。我无法更改元素值,我必须更改进入 POST 的实际 FormData。 我尝试更改 form.onsubmit 以更新值(适用于某些字段,但其
我正在尝试使用 FormData html5 api 设置多文件上传。问题是我无法删除 FormData 键上的数组索引。例如: if(editor.frmData){ editor.
我试图在提交表单时获取表单数据键值对对象,使用 new FormData()构造函数。但它总是返回空数据。 我已经尝试过event.persist()避免 react 事件池,但没有任何效果 expo
在 jQuery 代码中, var formData = new FormData($('#content-submit')[0]); formData.append("Title",
我正在使用 fetch API 从浏览器发送发布请求。这是我的代码: const headers = new Headers(); headers.append("Content-Type", "ap
你好,我有他的上传文件表格 $("#form").on('submit',(function(e) { e .preventDefault(); $.ajax({
我需要根据用户输入(从 html 表单发送)创建一个 formData,因为我需要修改图像图片(压缩/调整大小/裁剪),然后将新的 FormData 提交到服务器: $(document).r
我似乎对 FormData 为空有疑问。我正在尝试在单个 POST 请求中上传文件和 JSON。我尝试了各种各样的方法,但似乎没有任何效果。我想知道我是否在这里弄乱了一些基本的东西,但我似乎找不到任何
我需要在 FormData 中添加图像数组,但只有第一个图像通过。 我知道问题出在 JS 代码中,因为当我将表单直接发送到 php 页面时,它工作正常。 JavaScript var url = $(
我正在以非正常方式获取文件及其值。表单中没有实际输入。因此,我尝试将文件附加到 formData 以进行 ajax 提交。 每当我尝试使用以下方法提交表单时,我的文件都不会上传。因此,我附加文件的方式
formData 的参数之一可以包含对象吗? 如果我执行以下操作,该对象将在服务器端转换为字符串。 formData.append('first_name', 'takuya'); formD
我想将带有附加数据的图像从 React.js 发送到 Django 后端。当我使用 FormData() 创建表单数据时,它无法发送数组(因为它将其转换为字符串)。这是我的代码: let formDa
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-topic
我有一个 Web 应用程序,它使用 FormData 对象通过 jQuery.ajax() 上传。到目前为止,一切都很好。数据作为 multipart/form-data 发送,服务器解析它,没有问题
这个问题已经有答案了: FormData.get function is undefined (2 个回答) 已关闭 7 年前。 我正在尝试进行简单的 ajax 文件上传,但收到“未捕获的类型错误:f
我正在使用 Angular 5,这是 Angular 的新手,但我已经研究过很多 JavaScript 框架。我陷入了一个问题,下面是我现在面临的描述问题。 我已经创建了表单,我想在提交时发送到服务器
我正在关注How-to-submit-additional-form-data并有一个正在提交附加表单数据的工作文件上传,即。附加文本区域输入字段 description[],具有分块和多文件支持,无
我是一名优秀的程序员,十分优秀!