I have a very standard layout for an ajax.beginform with a callback on OnSuccess. But in IE8, the callback does not get called, but it works fine in Chrome.
I am including jquery.validate.min.js, jquery.validate.unobstusive.min.js, and jquery.unobstrusive-ajax.min.js in my view.
The view is used as a partial view, and contains all the scripts it needs, as well as the javascript function that the callback will call.
I will also note, that I had to upgrade my jquery.validate.min.js that came with the initial creation of the MVC3 project to one that would work properly with IE8 already.
Are there any known issues with why this would not work? Or am I missing something?
[cshtml]
<script type="text/javascript">
function FormSuccess(context) {
alert("FormSuccess()");
};
</script>
@using (Ajax.BeginForm("GetMessage", "Form", new AjaxOptions { OnSuccess = "FormSuccess" }))
{
[Controller]
[HttpPost]
public JsonResult GetMessage(MessageModel model)
{
return Json( success = true, message = "success" );
}
In Chrome, the callback is hit, but in IE8 I get a file download dialog. When the file is downloaded, I get a file containing the following:
{"success":false,"messages":"success"}
As you can see, it is a very simple thing I am doing here, but it just does not seem to want to work in IE8.
Any ideas?
UPDATE
I found out that because I am rendering a razor cshtml file form an ascx page, the AjaxOptions callbacks are not being called. I created a sandbox app that does the same thing, and if I have a cshtml render a partial cshtml, everything works fine, but if I have a aspx render a partial cshtml, the callbacks do not get called
following is incorrect
.change it to :
EDIT:
you have to return a complete View instead of json result.
if you want to sent ajax request and get JSON result you must send it via jquery ajax function.