Internet explorer in compatibility mode gets the data from the server in an ajax callback method, and pops-up a dialog if I want to save the data or open. How to get rid of that?
client says:
$.ajax({ type:'POST', data: $("#UIdlgHolder > form").serialize(), url: $("#UIdlgHolder > form").attr("action"), success: function (data, textStatus, jqXHR) { { alert(data.message); } }
server answers:
return new JsonResult { Data = new { result = false, message = "Yay!" } };
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.
Right click on JSON file, select open, navigate to program you want open with(notepad). Consecutive opens automatically use notepad.
To post JSON data to the server, we need to use the HTTP POST request method and set the correct MIME type for the body. The correct MIME type for JSON is application/json. In this POST JSON example, the Content-Type: application/json request header specifies the media type for the resource in the body.
Even though it's not supposedly the correct way, setting the content type to text/html made IE deal with this correctly for me:
return Json(result, "text/html");
Works in all the version that F12 tools gives you in IE9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With