CLod
CLod

Reputation: 917

jquery file upload dataType script IE issue

I still have troubles using jquery fileupload plugin, only on IE.

The javascript is something like this:

$('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();       
});

This is the request 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

I specify the dataType to be: 'script' and I return from server:

 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 ******************

And the response body is:

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);

On chrome, firefox, etc... all good.

On IE it ask me if I want to open or save the update_attachment.js ????

The other ajax calls work fine, it interprets the javascript response properly, only using fileupload no....

edit:

IE is not passing in the request header:

  X-Requested-With  XMLHttpRequest

Upvotes: 3

Views: 2746

Answers (1)

CLod
CLod

Reputation: 917

I think this answers my question

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 is not doing a XHR request...

Upvotes: 2

Related Questions