Title says it all, tried more ways than I can remember and I still can't get my callbacks to trigger. I'm using Rails 3.0.7 and Jquery 1.6, as well as latest jquery-fileupload plugin.
I've followed the recommendations of a few of the most relevant SO links to try and debug this, and so far at least I am able to send the file into Rails. However, when the response is returned IE9 refuses to do anything meaningful with it. Here's what I'm doing:
Rails view:
<form class="file_upload" action="/search/via_uploaded_file" encType="multipart/form-data" method="post" accept-charset="UTF-8">
<div style="margin: 0px; padding: 0px; display: inline;">
<input name="utf8" value="✓" type="hidden">
<input name="authenticity_token" value="whatevs">
</div>
<input id="uploaded_file" name="uploaded_file" type="file">
<input id="fileupload" name="commit" value="upload" type="submit">
</form>
rendering in rails controller:
render :json => data_to_form.to_json, :content_type => 'text/html'
fileupload
code:
$("#fileupload").fileupload
dataType: 'json' #have tried with and without this
add: (e, data) ->
data.submit() #this will 'force' the submit in IE < 10 (not in my case)
done: (e, data) ->
console.log('data')
#foobaz
fail: (e, data) ->
console.log('fail')
always: ->
console.log(data)
I know what you may be thinking - aha! He's adding the fileupload
js onto the submit button! However, if I don't do this IE9 simply refuses to do anything (nor to grab the filepath). Here are the headers that get generated:
and here's the response:
What's crazy is that even though I respond in rails as a text/html
(knowing that the iFrame request for IE doesn't know about xmlhttp, and that fileuploader
is expecting a JSON because I added it as a dataType
option) all I get back is a new page with the response body:
What am I doing wrong? I've spent days pondering over this and you will make my day by pointing me in the right direction. Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire