ajax form send notification jquery
I ve got a form which I am sending via jquery ajax. What I am trying to
achieve is: Before the form is sent there should be a notification
'sending' and after the request is done, this message should disappear and
there should be a message "sent". I am using pnotify. What I tried so far
is:
inProcess = function(){
m = $.pnotify({
title: "sending"
});
return true;
}
event.preventDefault();
$.ajax('',{
method: "POST",
data: myform.serialize,
beforeSend: inProcess,
complete: function(response){
$.pnotify({
title: "Sent",
type: "success",
opacity: "0.8",
delay: 5000
});
m.remove();
}
});
This one does not work:
For any reason the 'sent' is appearing before sending. Why?
The remove() function removes the notification before it is created, But
it is not removed completely, one can see that the 'sending' notification
is shifted down. How can I remove the notification completely?
Do I really need to wrap the 'sending' call inside a function, only
because beforeSend requires a true as return code? Or is there a more
elegant way?
No comments:
Post a Comment