代码中有错误吗?

I have the following code in jquery, what it does is when the user submits (button1) it goes script_1.php .In script_1.php file it returns "yes" if its true or false when it is not. My problem is even if the value submitted by script_1.php is 'yes' it is going to else part of the code instead of going to if part(if(data=='yes')).

Is there any problem with the code??

$(document).ready(function(){
$("#button1").click(function()
{
$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
    //checks if the id exists
    $.post("script_3.php",{ id:$('#id').val(),rand:Math.random() } ,function(data)
    {
        if(data=='yes')//correct id detail
        {
      //some other code
        }
 else 
      {
          $("#msgbox").fadeTo(200,0.1,function()
          { 
          //add message and change the class of the box and start fading
          $(this).html('NO ID...').addClass('messageboxerror').fadeTo(900,1);
        });        
      }

    });

script_3.php

$sql="SELECT id FROM parentid WHERE id='$id'";
 $result=mysql_query($sql);
$row=mysql_fetch_array($result);
if(mysql_num_rows($result)>0)
{
echo "yes";

}

Note: i have checked the syntax errors like closing,opening brackets or such errors everything is fine.I think there might me some error in jquery part.

Are you using a javascript debugger of some sort? Many browsers are starting to include them these days, but I prefer firebug for firefox above them all.

http://getfirebug.com/

With firebug you can set breakpoints in your javascript and see what is going on at every moment in your code.