I am using MVC C# along with Jquery.
I have a partial view that’s need to be updated every time the user modify some data from the view. The problem is that the partial view is not updated. How can update the partial view?
jquery code from the partial view (WorkReport)
$("#modify").click(function () {
var duration = $("#newDuration").val();
var date_param = $("#dateParam").val();
$.ajax({
url: '@Url.Action("ModifyDuration", "ViewWork")',
type: 'post',
data: { newDuration: duration, id: psm_id, date: date_param },
dataType: 'text',
traditional: true,
beforeSend: function (jqXHR, settings) {
$.mobile.showPageLoadingMsg();
},
success: function (data) {
$("#workList").html(data).trigger('create');
$.mobile.hidePageLoadingMsg();
},
error: function (jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
}
}
});
});
Controller code:
[HttpGet]
public PartialViewResult GetWorkList(string date)
{
model.workList = workList;
return PartialView("WorkReport", model);
}
[HttpPost]
public ActionResult ModifyDuration(string newDuration, string id, string date)
{
DataOperation dataOperation = new DataOperation();
dataOperation.UpdateWorkDuration(newDuration, id);
return RedirectToAction("GetWorkList", new
{
date = date
});
}
You Can use this but please sure that select correctly page.or use load