Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE9 JSON Data "do you want to open or save this file"

Started testing my jQuery applications with IE9. Looks like I may be in for some trouble here. I noticed that when I return JSON data back to the Javascript methods I always get this Prompt that says: "Do you want to open or save this file?" and provides me with 3 buttons: Open, Save and Cancel. Of course, my javascript is taking actions based on the values set in the JSON object but since IE9 doesn't pass it over to the script, I cannot execute the follow up action from there on.

Anyone else facing this issue? Here is a snapshot.enter image description here

like image 782
Anup Marwadi Avatar asked Mar 22 '11 09:03

Anup Marwadi


People also ask

How do I open a JSON file in Internet Explorer?

To open a JSON file in an IE window you need to create a wrapper function to open a new window and then to inject the JSON file's text content inside of a <pre> or <code> block.


1 Answers

If anyone is using ASP.net MVC and trying to fix this issue - I used the following built in methods in the MVC framework. Simply update the content Type and encoding on the JsonResult.

public ActionResult Index(int id) {         // Fetch some data         var someData = GetSomeData();          // Return and update content type and encoding         return Json(someData, "text/html", System.Text.Encoding.UTF8,                         JsonRequestBehavior.AllowGet); } 

This fixed the issue for me!

like image 128
Deano Avatar answered Sep 21 '22 17:09

Deano