Ajax不发送序列化数据

时间:2015-10-29 17:03:27

标签: php jquery ajax

我的jQuery有问题。我发送了一个AJAX请求,并且没有将序列化数据发送到PHP文件。这是jQuery:

var str = $("#emailverify").serialize();
$.ajax({
    url: 'emailverify.php?task=verificacion',
    type: 'post',
    data: str,
    beforeSend: function() {
        $(".msg_veri").html('<img src="images/ajaxcart_loader.gif />');
    },
    success: function(data) {
        //alert(data);
        $(".msg_veri").html(data);
    },
    complete: function() {
        //$("#btnsendmail").attr( "disabled", false );
        $("#btnvalidatemail").attr("disabled", false);
    }
});

这是表单的HTML:

<form action="" method="post" id="emailverify">
    <div class="lad_correos">
        <input type="hidden" id="contacto" name="contacto" value="<?php echo $_SESSION['cliente']['cookdownnlitemcontacto']; ?>">
        <input type="hidden" id="susnume" name="susnume" value="<?php echo $susnume; ?>">                
        <div class="txt_label">Correos electr&oacute;nicos:</div>
        <input id="email1" name="email1" class="text required email" type="text" placeholder="micorreo@dominio.com" value="<?php echo $emailistos[0]; ?>"/><br>   
    </div>
    <div class="botones">
        <div class="btn_send">
            <!--<input type="button" class="button btn-success" style="visibility:hidden;" value=" Verificar correos " onclick="javascript:sendmail();" id="btnsendmail" />-->
            <!--<input type="button" class="button btn-info" value=" Validar c&oacute;digos " style="visibility:hidden;" id="btnvalidatemail" onclick="javascript:validatemail();" />-->    
            <input type="button" class="button btn-success" onclick="javascript: closepopup();" value=" Verificar correos" id="btnverify" /> <!-- onclick="javascript:verify();" --> 
        </div>
    </div>
</form>

这是它应该在PHP中执行的地方,但它没有从表单中接收任何后期数据:

<?php  include('../prgs/dbconnect.php');
    $sus_nume = $_POST["susnume"];
    $codigoauto = rand(1000, 9999);
    $estado = 1; // email supuestamente enviado 1

    if ($_POST['email1']) {
        if ($_POST['email1'] != '') {
            $email1 = $_POST['email1'];
            $sqlselect = "select correo from verificacion_correos where susnume='" . $sus_nume . "' and correo='" . $email1 . "';";
            $res1 = mysql_query($sqlselect);
            $arr1 = mysql_fetch_array($res1);
            $mailchk1 = $arr1[0];
            if ($mailchk1 != $email1 && $mailchk1 != null && $mailchk1 != "") {
                $sqlinsert = "insert into verificacion_correos(`susnume`, `correo`, `codigoverificacion`, `estado`, `fecharegistro`) ";
                $sqlinsert .="values('" . $sus_nume . "','" . $email1 . "','" . $codigoauto . "','" . $estado . "','" . fecha_hora(2) . "');";
    //$sqlinsert .= "update suscriptores set email='" . $email1 . "' where sus_nume=" . $sus_nume . ";";
                $insvalidation = mysql_query($sqlinsert) or die(mysql_error());
    //$insSus = mysql_query($sqlIns) or die(mysql_error());
            }
        }
    }
    echo "1_|_" . $sqlinsert;

0 个答案:

没有答案