I am submitting my form with jQuery using an AJAX request. After successfully submitting the form I want to show a success message for 3 seconds and then I want to hide this success message. To do that I am using following code using the jQuery delay()
method.
But somehow this delay()
method is not working as I expect it to. It's immediately showing the message and then hiding the message.
I want to show the message for 3 second then it should be hidden. Can you please tell me why it's not working?
function upload_project_doc(element, event) {
e = $(element);
event.preventDefault();
$('#up_project_doc_img').show();
var formData = new FormData(e.parents('form')[0]);
$.ajax({
url: 'up_project_doc.php',
type: 'POST',
xhr: function () {
var myXhr = $.ajaxSettings.xhr();
return myXhr;
},
success: function (data) {
$("#project_up_result").html(data);
$('#project_up_result').show();
$('#project_up_result').delay(3000).fadeOut('slow');
$('#up_project_doc_img').hide();
getProjectForm(<? php echo $p_id; ?>);
},
data: formData,
cache: false,
contentType: false,
processData: false
});
}
My form is little bit big but it's look like that :
<td align="left" width="160">
<button class="search_submit" onclick="upload_project_doc(this,event);">
<b>Upload</b>
</button>
</td>