Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internet Explorer wants to download the JSON result from posting files #5

Closed
jennings opened this issue Dec 22, 2012 · 10 comments
Closed

Comments

@jennings
Copy link
Collaborator

When uploading a file with Internet Explorer 9, the browser asks the user whether to open or save the JSON result. Consequently, the user gets a confusing dialog box and the indicators of the upload status never change away from "uploading" and the spinning throbber.

  1. Open http://dbinbox.com/whatever in IE 9
  2. Use Choose File to upload any non-empty file
  3. When the file finishes uploading, the user is asked to open or save a file with a nonsense filename that contains JSON data.

ie-download

json-result-download

@jennings
Copy link
Collaborator Author

I'm not sure what the cause of this is, but I'll try to find out and update this issue.

@christiangenco
Copy link
Owner

Hmmm, not sure why that would be. I'm using jQuery's $.post to handle the AJAX request, if it helps you track it down!

Unfortunately, I don't have a windows box running IE9 I can test this on.

@jennings
Copy link
Collaborator Author

I think this is an issue with IE and its interaction with jQuery File Upload. They have issue blueimp/jQuery-File-Upload#1795 for this.

It looks like the solution is to return "text/plain" if HTTP_ACCEPT doesn't inclue application/json.

@jennings
Copy link
Collaborator Author

I don't have a way to test it because I don't have a Ruby dev environment, but I think the changes I pushed to my ie9-content-type branch might do it. I've never used Sinatra (or really even Ruby) before, though, so truly I have no idea if this will work.

@christiangenco
Copy link
Owner

I couldn't get request.accept? working in Chrome or Safari, so I'm just checking the user agent string for Internet Explorer 6-9:

content_type (request.user_agent.index(/MSIE [6-9]/) ? 'text/plain' : :json)

Did that fix it?

Side note: I find it hilarious that we're able to fix bugs in a Sinatra project serving files to IE when you can't run Ruby and I can't run IE.

@jennings
Copy link
Collaborator Author

Hooray! It seems to work now. Thanks!

Yeah, I also though it was funny we both are missing something in our environments (in my case, pretty much the entire thing). I feel like I'm in the movie See No Evil, Hear No Evil.

@christiangenco
Copy link
Owner

Haha, yes!

If you get a chance, I'd highly recommend giving Ruby a try. As with most linux-centric development environments, it's not quite as smooth on Windows as it is on a Unix system, but it's still super awesome.

@vsapram
Copy link

vsapram commented Jul 1, 2013

after adding this line
response.setContentType("text/plain");
It is working with jetty server.
But in tomcat still it is showing the error?
Please suggest some thing for this. Thks in advance.

@christiangenco
Copy link
Owner

@vsapram I've got no idea, I'm afraid :( I've never used tomcat.

Is there a compelling reason why you can't use jetty?

@MikeInSwitzerland
Copy link

Annoyingly, Internet Explorer doesn't automatically open .json files.

The solution is to run a simple .reg file on your PC, to make it behave normally:

http://www.mikesknowledgebase.com/SampleCode/MakeIEshowJSONdata.zip

You'll need Admin rights to run this .reg file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants