我需要使用必须在IE9中支持的ajax上传文件.我正在使用这里提到的FormData .我的代码看起来像这样:
var files = new FormData();
JQuery.each($('#file')[0].files, function (i, file) {
files.append('file', file);
});
$.ajax({
type: "POST",
url: '/url',
cache: false,
contentType: false,
processData: false,
data: files,
...
});
Run Code Online (Sandbox Code Playgroud)
这在Safari和Firefox中工作正常,但在IE9中失败,因为IE9不支持FormData.我尝试通过设置发送作为文件:
data: $('#file')[0].files[0]
contentType: 'multipart/form-data'
Run Code Online (Sandbox Code Playgroud)
这会失败,因为数据是以url编码的形式发送的,并且无法在java端解析.任何有关如何解决这个问题的帮助或指针将不胜感激.我需要适用于所有浏览器的东西.
编辑:我不需要任何上传进度条,因为文件通常很小.我不需要上传多个文件.我只需要一个文件上传.
ajax jquery internet-explorer file-upload multipartform-data
I have a table say types, which had a JSON column, say location that looks like this:
{ "attribute":[
{
"type": "state",
"value": "CA"
},
{
"type": "distance",
"value": "200.00"
} ...
]
}
Run Code Online (Sandbox Code Playgroud)
Each row in the table has the data, and all have the "type": "state" in it. I want to just extract the value of "type": "state" from every row in the table, and put it in a new column. I checked out several questions on SO, …