if(($out).filter(':contains(Invalid)'))

That is always going to be "true" since it returns a jQuery object regardless of whether there are any matched elements. Try this instead:

if(($out).filter(':contains(Invalid)').length)


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Mar 10, 2009, at 11:32 AM, brightdad...@googlemail.com wrote:


Hi Experts,

I am trying to do something like this;

 $("form#submit").submit(function(){
       var name     = $('#name').attr('value');
       var $out = $("#message");

       //Send the request
       $.ajax({
           type: "POST",
           url: "post.php",
           data: "oname="+name,
           complete: function(data){
               $out.html(data.responseText);

               if(($out).filter(':contains(Invalid)'))
               {
                   $out.fadeIn();
                   $(".txtHint:visible").slideDown("slow");
                   $(".client").hide();
               }else if($out).filter(':contains(successfull)')){
                 $out.fadeIn();
              }
to be able to determine what to hide and display depending on the
result recieved from the query.
This doesnt not behave as exoected - do any know  exactkly what i am
doing wrong here?

Reply via email to