MVC.Net, Ajax.BeginForm, jQuery and IE8
I am trying to use the "standard" MVC.Net unobtrusive JavaScript AJAX pattern as described here:
http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-ajax.html
More specifically, the template might look like this:
// IN VIEW
@using (Ajax.BeginForm("action1", "controller1",
null,
new AjaxOptions()
{
HttpMethod = "POST",
OnSuccess = "successHandler",
},
new { id = "formId" }
))
{
@Html.TextBoxFor(m => m.ModelItem)
<input type="submit" value="Go" />
}
I believe I created the required elements in the Web.Config along with what appears to be working jQuery code. The "action1" method on the controller is set to return a JsonResult, perhaps like this:
// In the CONTROLLER response (and with MODEL it doesn't matter here)
public JsonResult action1(MyModel model)
{
if (ModelState.IsValid)
{
return Json(new { statusCode = 1 });
}
return Json(new { statusCode = 0 });
}
This pattern works great when I'm using "modern" browsers; that is, the latest versions from three major suppliers. However, when I try to do anything with Internet Explorer 8 (and presumably before), I get a File Download - Security Warning dialog box. I believe this dialog comes up because the browser doesn't know how to handle the content type generated by JsonResult (application / json) and therefore prompts the user to save the return value. However, changing the content type in the JsonResult method, such as "text / plain" or "text / html", also does not work. Instead, IE8 redirects the browser window to display the original JSON sent back. None of these steps work for me.
I make sense that the problem is with the vertex, i.e. the "ajaxification" of the Ajax.BeginForm just doesn't happen in IE8, but I could be wrong and I don't know what to do about it anyway.
Any hints?
Thank.
source to share
No one has answered this question yet
Check out similar questions: