使用变量查询并在 div 和 ajax 中显示结果时出现问题

problems when using a variable query and display the results in a div with ajax

我需要你的帮助!并分配来自 php 文件的变量值以与我的查询进行比较? 2. 语法不正确。 3.作为打印数据到我处同div的"success"?

------我的index.html------

<div id="formulario">
    <form method="post" id="formdata">
        <label for="nombre">Nombre: </label><input type="text" name="curp" id="curp" required="required"></br>

        <input type="button" id="botonenviar" value="Enviar">
    </form>
</div>
<div id="success" style="display:none">Sus datos han sido recibidos con éxito.</div>
<div id="fail" style="display:none">Se ha producido un error durante el envío de datos.</div>

--------我的php------

my connexion is good but..

$var= $_POST[‘curp’];    <------ is not correct!!!! 

$query = mssql_query("SELECT * FROM SOLICITUD_ACTIVOS_2010 WHERE ID_SOLICITUD = $var");


if (mssql_num_rows($query) == 0) { 
    echo json_encode(0);
} else {
    echo json_encode(1);
}

--------我的script.js----------------

$(document).ready( function() {  
$("#botonenviar").click( function() {     
    if(validaForm()){                              
        $.post("enviar.php",$("#formdata").serialize(),function(res){
            $("#formulario").fadeOut("slow");   
            if(res == 1){
                $("#success").delay(500).fadeIn("slow");
            } else {
                $("#fail").delay(500).fadeIn("slow");   
            }
        });
    }
});    

});

$var= $_POST[‘curp’]; // should be single quotes('curp') or double quotes("curp")

你这里的语法因为引号不正确,我不知道你是怎么得到那种类型的引号的,但事实并非如此。单引号 (') 或双引号 (").

并且您想将返回的数据添加到您的 #success div?然后使用

$('#success').append(res); or $(res).appendTo('#success');

希望对您有所帮助。