Created
December 20, 2012 13:41
-
-
Save anonymous/4345376 to your computer and use it in GitHub Desktop.
Coffeescript snippet for use with jQuery-File-Upload that works with the iframe transport plugin as well as ajax which means it works in IE9 as well as Chrome etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$form.fileupload | |
dataType: "json" | |
done: (e, data, extra) -> | |
result = if data.result? | |
data.result | |
else | |
data = JSON.stringify(data).replace(/"name":"utf8","value":"[^"]*"/, '"name":"utf8","value":"REMOVED"') | |
JSON.parse(data).result | |
console.log result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyController < ApplicationController | |
def my_action | |
# Do whatever you need to do | |
respond_to do |format| | |
format.js { render json: to_json(@agent) } | |
format.html { render text: "<textarea data-type=\"application/json\">#{to_json(@agent)}</textarea>" } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment