$.post data html returns null


$.post data html returns null

当我对php文件使用$.post时,遇到了一些奇怪的问题。文件本身没有任何post-echos"someresult",当我去$.post时,post数据的html()为null。。。帮助plz

$('#podborform').submit(function(){
    var phone = $('#tour_selection_phone').val();
    if(phone != null && phone != '' && phone.length >= 7){
        var values = $(this).serialize();
        var qwer = String('captcha');
        var url = $(this).attr( 'action' );
        $.post( url, values,
            function( data ) {
                var content1 = $( data ).html();
                //content = String(content);
                //alert(qwer+'  -  '+content);
                if(content1 == qwer){
                    alert('Вы не правильно ввели код с картинки, попробуйте еще раз!');
                }
                if(content1 == 'false'){
                    alert('Извините произошла ошибка!');
                }
                if(content1 == 'true'){
                    alert('Ваша заявка успешно отправлена!');
                }
            }
        );
    }else{
        alert('Вы не ввели все обязательные поля!');
    }
    return false;
});

它连接到包含以下内容的php:

<?php
class mailer{
    //var $fields = array();
    function __construct(){
        if($this->captcha()){
            $this->sendmail();
        }else{
            exit('false');
        }
    }
    function sendmail(){
        foreach($_POST as $key=>$post){
            $text .= $key.': '.$post.PHP_EOL;
        }
        if(mail("123@gmail.com", "the subject", $text,
            "From: sales@123.ru'r'n"
           ."Reply-To: {$_POST['email']}'r'n"
           ."X-Mailer: PHP/" . phpversion())){
                exit('true');
            }else{
                exit('false_mail');
        }
    }
    function captcha(){
        require_once('recaptchalib.php');
        $privatekey = "123123";
        $resp = recaptcha_check_answer ($privatekey,
                                      $_SERVER["REMOTE_ADDR"],
                                      $_POST["recaptcha_challenge_field"],
                                      $_POST["recaptcha_response_field"]);
        if (!$resp->is_valid) {
          // What happens when the CAPTCHA was entered incorrectly
          echo 'captcha'; exit;
        } else {
            unset($_POST["recaptcha_challenge_field"],
                                      $_POST["recaptcha_response_field"]);
          return true;
        }
    }
}
    $mail = new mailer;
?>

.html获取包含HTML的

示例

$('<div><img/></div>').html() // returns '<img/>'
$('test').html() // returns null

您可以直接使用data。它将包含作为字符串的响应

if(data == qwer){
}
if(data == 'true'){
}

您忘记了对象mailer构造上的():

$mail = new mailer;

应该是

$mail = new mailer();