jQuery Ajax问题

im comparing string to make ajax work here is html page

 $("#contact").submit(function(){

       $.ajax({
         url:"contact_ajax.php?action=contact",  data:"name="+$('#name').val()+"&email="+$('#email').val()+"&message="+$('#message').val()+"&lang=<?php echo $_GET['lang']; ?>",
          success: function(html){
         // $("#script").html(html)
         //alert(html)
         switch(html){
           case "name required":
           jQuery('#name').hide()
           break;
         }
         }
       })

})

here php page:

header('Content-Type: text/html; charset=iso-8859-1',true);

 if($_GET["action"]=="contact"){


if(trim($_GET["name"])=="") echo "name required"; else{   if(trim($_GET["name"])!=="")   echo "name filled"; }

so if "name required" is echo back to the page this: jQuery('#name').hide() should happen but nothing happens??

Try to alert html string that you get in the success handler. May be its not matching the required condition.

Try this

switch($.trim(html)){
           case "name required":
           jQuery('#name').hide()
           break;
         }