setTimeout() not timing out
Hi,
In using setTimeout() to show and hide a message the message just flashes on and off. Timer is not working.
Hope someone can spot something wrong here.
UPDATE:
I commented out window.location.assign("fields.php"); and setTimeout works properly. See 5. below.
-
if(update) {
$.ajax({
type: "POST",
url: "changeData.php",
data: { "col":col, "update":update},
dataType: "text",
success: showChangedData
}); // ajax
function showChangedData(data) {
successMsgShow();
} // showCh
}
else {
$('#succMsg').append("<h5><span style='color:red'>You Didn't Enter revised Data.</span></h5>");
}
});// indata
// =============== Success Message with Time Delay ===================
function successMsgShow() {
$("p").append('<h3> <span style="color:red">Data Revised Successfuly</span></h3>');
setTimeout(successMsgHide, 5000); // show message for 5 seconds
- // Flashes on screen w/ no delay
window.location.assign("fields.php"); // run page again showing revised data
}
function successMsgHide() {
$("p").hide();
}