gpt4 book ai didi

jquery文件上传dataType脚本IE问题

转载 作者:行者123 更新时间:2023-12-01 01:27:28 25 4
gpt4 key购买 nike

我在使用 jquery fileupload 插件时仍然遇到问题,仅在 IE 上。

JavaScript 是这样的:

$('input#fileupload').fileupload({
url: '/upload_attachment.js',
dataType: 'script',
................
................

$('input#realupload').bind('change', function(e){
$('#fileupload').fileupload('send', {
dataType: 'script',
files: e.target.files || [{name: this.value}],
fileInput: $(this)
});
e.preventDefault();
});

这是请求 header :

 Key    Value
Request POST /holdings/183400184/upload_attachment HTTP/1.1
Accept text/html, application/xhtml+xml, */*
Referer http://192.168.1.209:3000/holdings/183400184
Accept-Language en-NZ
User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Content-Type multipart/form-data; boundary=---------------------------7dc1d02610132
Accept-Encoding gzip, deflate
Host 192.168.1.209:3000
Content-Length 196
Connection Keep-Alive
Cache-Control no-cache
Cookie xxxxxxxxxxxxxxx

我将数据类型指定为:“script”,然后从服务器返回:

 Key    Value
Response HTTP/1.1 200 OK
Content-Type text/javascript; charset=utf-8
Cache-Control max-age=0, private, must-revalidate
X-Ua-Compatible IE=Edge
X-Runtime 4.625297
Server WEBrick/1.3.1 (Ruby/1.9.3/2011-10-30)
Date Wed, 25 Jan 2012 02:52:48 GMT
Content-Length 345
Connection Keep-Alive
Set-Cookie ******************

响应正文是:

var li = '<li>';
li += '<img alt="Paperclip" src="/images/paperclip.png?1323904510" /> ';
li += '<a href="/XXXXX/183400184/download_attachment/980191034">test.txt</a> <img alt="Cross_16x16" data_url="/XXXXX/183400184/destroy_attachment/980191034" src="/images/cross_16x16.png?1327452770" />';
li += '</li>';
$('ul#attachments').append(li);

在 Chrome、Firefox 等上...都很好。

在 IE 上,它询问我是否要打开或保存 update_attachment.js ???

其他ajax调用工作正常,它正确解释javascript响应,仅使用fileupload no....

编辑:

IE 未传入请求 header :

  X-Requested-With  XMLHttpRequest

最佳答案

我认为这回答了我的问题

forceIframeTransport

Set this option to true to force iframe transport uploads, even if the browser is capable of XHR file uploads. This can be useful for cross-site file uploads, if the Access-Control-Allow-Origin header cannot be set for the server-side upload handler which is required for cross-site XHR file uploads.

Type: boolean
Default: false

IE 没有执行 XHR 请求...

关于jquery文件上传dataType脚本IE问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8997366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com