I am having some problems with a jquery script that I am writing. The problem is after I receive the data from the php file jquery seems to skip the if statement. I am logging to console and it is showing yes/ no depends on email address. I am enclosing my scripts in case someone can help me.
<script src="javascripts/jquery-1.2.6.js" type="text/javascript" charset="utf-8"></script> <script src="javascripts/jquery.validate.js" type="text/javascript" charset="utf-8"></script> <script src="javascripts/jquery.corner.js" type="text/javascript" charset="utf-8"></script> <script src="javascripts/jquery.lightbox.packed.js" type="text/ javascript"></script> $(document).ready(function(){ $("#email").blur(function(){ var post_string = $(this).val(); $("#msgbox").removeClass().addClass('messagebox').text ('Checking...').fadeIn(1000); $.post("php/email.php",{ email_check: post_string} ,function(data){ console.log(data); // show data value in console if(data=='no') { // email not avaiable <------------------------- Skipping this area $("#msgbox").fadeTo(200,0.1,function(){ $(this).html('email address already exists').addClass ('messageboxerror').fadeTo(900,1) }); } else { // email avaiable <-------------------------- Always gos here no matter what $("#msgbox").fadeTo(200,0.1,function(){ $(this).html('email available to register').addClass ('messageboxok').fadeTo(900,1); }); } // end if }); // end post }); // end email blur }); // end doc ready PHP FILE if(isset($_POST['email_check'])) { $email = $_POST['email_check']; require_once('config.inc.php'); require(MYSQL); $result = @mysql_query("SELECT * FROM members WHERE (user_email = '$email')"); $row_num = mysql_num_rows($result); if( $row_num > 0){ // "unavailable to register"; $valid = "no"; }else{ // "available to register"; $valid = "yes"; }; echo $valid; mysql_close(); } I have been working on this all day and can not figure out why the data is skipping the if statement. if you have any ideals please let me know.