I have the following code snippet. Basically there is a pop up dialog which has name field and comment field and when user clicks on OK button, the name gets updated on the user interface. But in order for me to see the updated updated name on the UI, I have to refresh the page. I tried doing the reloading of the page using the commented line of code for the OK button (/*location.reload(true);*/ ) as shown below in the code but this basically reloads the page.
I would like to see the updated content on the User Interface as soon as OK button is clicked and the dialog gets closed.Could anyone tell me what alternative approach or any fix can be applied in the current code to achieve my requirement?
$("#editName").click(function () {
$('#editName').popModal({
html: $('#edit_name').html(),
onOkBut: function () {
var editNameVal = $("#editName").val();
var editNamecomment = $("#editNameComment").val();
var url = https://editwebservice:8443/editName
if (isEmpty(url)) { alert("Invalid URL for Edit Name "); return false; }
var ajaxRequest = jQuery.ajax({
data: {
employee_id: regman.employee.id,
employee_supervisor_id: employeesupervisor_.employee_supervisor_id
},
dataType: "json",
method: "GET",
url: url
})
.done(function (data_, textname_, jqXHR_) {
$.extend({ alert: function (message, title) {
$("<div></div>").dialog( {
buttons: { " OK ": function () {/*location.reload(true);*/ $(this).dialog("close"); } },
close: function (event, ui) { $(this).remove(); },
resizable: false,
title: title,
modal: true,
position: { my: 'top', at: 'top+30' }
}).text(message);
}
});
$.alert("employee name Updated !!","employee name" );
if (data_.name != "SUCCESS") { return false; }
})
.fail(function (jqXHR_, textname_, errorThrown_) {
alert("Error in Updating employee supervisor Service : ");
return false;
});
}// END of function()
});
});