I am making a jQuery Ajax request to an ASP.NET MVC controller using the jQuery Form plugin.
The call works fine, but when I'm parsing the expected JSON I get the expected result in Firefox, but I get null in Internet Explorer.
The Ajax call is like this:
var options = {
iframe: true,
dataType: 'json',
success: function (result, status) {
$.unblockUI();
_editingEmail = false;
if (result.Sent === true) {
... Do something
}
$("#messageSentResult").html("
},
error: function (xhr, textStatus, errorThrown) {
$.unblockUI();
alert(textStatus);
},
beforeSubmit: function () {
$.blockUI({
message: '
Processing...
'});
}
};
$('#myForm').ajaxForm(options);
This is my controller:
[HttpPost]
public FileUploadJsonResult MyMethod()
{
... Do something
if(ValidationFails())
{
return new FileUploadJsonResult { Data = new { Sent = false, Message = "The operation was not successful." } };
}
return new FileUploadJsonResult { Data = new { Sent = true, Message = "The operation succeeded." } };
}
The FileUploadJsonResult class looks like this:
public override void ExecuteResult(ControllerContext context)
{
this.ContentType = "text/html";
context.HttpContext.Response.Write("");
base.ExecuteResult(context);
context.HttpContext.Response.Write("");
}