I am having an ajax call with is working fine in Mozilla and Chrome, but not in IE 9.0. The code is as follows:
I am not able to understand why is the myDiv not being refreshed. The save is done accordingly and it is just that the myDiv isn`t being refreshed in IE9.0.
$.ajax({
cache: false,
contentType: "application/json; charset=utf-8",
dataType: "html",
url: "@Url.Action("Save", "Employee")",
data:
{
Id: $("#ID").val(),
},
success: function (data)
{
$("#myDiv").html(data);
},
error: function (request, status, error)
{
}
});
<div id="myDiv">
@{Html.RenderPartial("NewPage", Model);}
</div>
NewPage.cshtml
@model MvcUI.Models.myModel
<div id="GridDiv">
<table>
</table>
</div>
Controller:
[Authorize]
public ActionResult NewPage( int Id)
{
return PartialView(new myModel(Id));
}
[Authorize]
public ActionResult Save(int Id)
{
myModel.Save(Id);
return RedirectToAction("NewPage", new {Id = Id});
}
observation
I have been doing various tests and observed the following behaviours:
In debug mode:
1. First time I do save, save done and table refreshed.
2. second time, the save done and table refreshed.
3. When I do it for the 4th time, the save done, but doesnt reach ActionResult NewPage( int Id), table doesn`t refreshed but some old data displayed…!
In deployed mode:
1. Only First time I do save, save done and table refreshed.
2. Second time, it only saves but does not refresh table data!
I don`t have any error or exception.
Have you tried setting the response-expiry headers? I have had issues where IE did not appear to reload the page when you do not set the following:
I’ve put them in ASP tags, but feel free to do this in your controller if you prefer (rather than repeat it in every action, possibly create an initialisation method)
EDIT:
As per @learning’s comment, one can also use the OutputCache attribute to do effectively the same thing