small tweak help need with jquery ajax call

while, working with my code, i am working on showing a message and hiding it after 5 seconds, but due to some reason, its is not working, i am going nuts here and its late now

here is my code snippet:

$("#updatefeedback").bind("click",function(){
            var data = $("form").serialize();
            $.post('sbtfeedback.cfm',data, function(data) {
                  $("#feedback_response").html(data).text()
            });
      });

my server-side file returns like this

<cfif len('FORM.sbname') IS 0>
    Error! Please Provide Your Name
    <cfelseif len('FORM.sbemail') IS 0>
    Error! Please Provide Your Email
    <cfelseif isDefined('FORM.sbcomments')>
    Error! Please provide Some Comments
<cfelse>
Cool! We did it
</cfif>

so minifying all tasks, i am actually returning the code rather than some kind of variable

the issue i am facing is, i am able to show a message but unable to hide it, don no why, what i m missing

Guide
LVL 16
Gurpreet Singh RandhawaWeb DeveloperAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
leakim971Connect With a Mentor PluritechnicianCommented:
>it just displays only one time and then it does not show up for any other message or for the same message

If you want replace .fadeIn("fast") by show();
$("#updatefeedback").bind("click",function(){
            var data = $("form").serialize();
            $.post('sbtfeedback.cfm',data, function(data) {
                  $("#feedback_response").html(data).text();
                  $("#feedback_response").fadeIn("fast");
                  setTimeout(function() { $("#feedback_response").fadeOut("fast"); }, 5000);
            });
      });

Open in new window

0
 
leakim971PluritechnicianCommented:
what about :
$("#updatefeedback").bind("click",function(){
            var data = $("form").serialize();
            $.post('sbtfeedback.cfm',data, function(data) {
                  $("#feedback_response").html(data).text();
                  setTimeout(function() { $("#feedback_response").fadeOut("fast"); }, 5000);
            });
      });

Open in new window

0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
but settimeout is the better way of doing it, i was thing if we can use OnComplete or something that can help
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
ok so i noted one things,

it just displays only one time and then it does not show up for any other message or for the same message
0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
Thanks, Although i was looking some evnt callback method like oncomplete or onSendBefore but this worked for me for the time being, so its good

Thanks
0
 
leakim971PluritechnicianCommented:
onSendBefore is between line 2 and 3
oncomplete is on line 4

if you really need to do something inside the ajax process with jQuery.post use jquery.ajaxsetup & co : http://api.jquery.com/jQuery.ajaxSetup/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.