Searching variables for an ID

Searching variables for an ID

Hey,

I hope I won't get banned for spamming these forums with questions, but here we go... 

I am trying to search an AJAX response for an ID, but it is not working as intended.

  1. // Some code omitted
  2.       success: function(result) {
  3.             $('#load').fadeOut(250, function() { // Fading out my loading gif
  4.             $(this).remove(); // Removing it
  5.              // With the if sentence below, I want to check if the result contains a form with the ID of "memberForm", but the sentence always evaluates as true, which is essentially my problem
  6.             if ($(result).find('#memberForm').length == 0) {
  7.                   // Login failed - show error messages
  8.                    $('#loginResult').hide().append('<div class="response">' + result + '</div>').fadeIn(1500);
  9.              }

  10.              else {
  11.                      // Code to execute if #memberForm was found
  12.              }
  13.       });
  14. }

So, to sum up the problem: I want to search the result variable for a form with the ID of "memberForm". If it is not found, that means the login was not successful and therefore error messages should be shown (that is what happens within my if sentence braces). If memberForm was found (the else sentence), then that code should be executed. But my if sentence always validates to true, so apparently there is something wrong with it. These are the possible return values that will be stored in the result variable:


If the login was successful:
<form method="post" name="memberForm" id="memberForm" action="logout.php">this is the form</form>

Not successful:
<br /><div class="validation" id="logfail">Login failed. Invalid login combination or inactive account.</div>


Any help is much appreciated. Thanks!