Reputation: 501
I have an insert statement applied using AJAX, when I apply fadeOut function to that the success message disappears but when I try inserting another value, the success message doesn't appear anymore although value is inserted in the database.
$(document).ready(function(){
$("#insert").click(function(event){
event.preventDefault();
$.ajax({
url:"insert_back.php",
method:"post",
data:$('form').serialize(),
dataType:"html",
success:function(msgStr){
$("#Imsg").html(msgStr).fadeOut(3000);
}
})
})
})
Upvotes: 2
Views: 102
Reputation: 2233
Before submitting the form add $("#Imsg").html('').fadeIn(0);
$(document).ready(function(){
$("#insert").click(function(event){
event.preventDefault();
$.ajax({
url:"insert_back.php",
method:"post",
data:$('form').serialize(),
dataType:"html",
beforeSend: function() {
$("#Imsg").html('').fadeIn(0);
},
success:function(msgStr){
$("#Imsg").html(msgStr).fadeOut(3000);
}
})
})
})
Upvotes: 2
Reputation: 1861
In success function
Change $("#Imsg").html(msgStr).fadeOut(3000)
; this to $("#Imsg").show().html(msgStr).fadeOut(3000);
Upvotes: 2