Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中使用ajax检查电子邮件id是否存在?_Php_Ajax - Fatal编程技术网

如何在php中使用ajax检查电子邮件id是否存在?

如何在php中使用ajax检查电子邮件id是否存在?,php,ajax,Php,Ajax,我必须检查电子邮件id是否存在。我知道这个问题是问服务器时间,我也在谷歌上查过,但仍然得到这个问题。我试过一些代码,但我不知道哪里错了。你能帮我吗 <input type="email" name="email" id="email"> <div id="status"></div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/

我必须检查电子邮件id是否存在。我知道这个问题是问服务器时间,我也在谷歌上查过,但仍然得到这个问题。我试过一些代码,但我不知道哪里错了。你能帮我吗

  <input type="email" name="email" id="email">
  <div id="status"></div>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
     $("#email").keyup(function() {
        var name = $('#email').val();
        if(name=="")
        {
            $("#status").html("");
        }
        else
        {
            $.ajax({
                type: "POST",
                url: "process.php",
                data: "email="+ name ,
                success: function(html){
                    $("#status").html(html);
                }
            });
            return false;
        }
    });
});
</script>
Process.php


您需要像这样发布数据:

$.ajax({
    type: "POST",
    url: "process.php",
    data: {email: name},//<--- Look here
    success: function(html){
        $("#status").html(html);
    }
});

哦,在您的php代码中,使用mysqli_escape_string对字符串进行转义,以避免mysql注入。

感谢您回复Zeus先生,我已经尝试过了,但仍然没有采取任何行动taking@NarendraVerma放一个警告HTML;在success函数中输入一行,以查看实际返回的内容。若警报根本并没有被调用,那个就意味着发布数据(可能是url)有问题;无输出return@NarendraVerma是否调用了警报函数或警报函数,但弹出窗口为空。我刚刚测试了ajax代码,效果很好。是的,宙斯先生,我发现了问题。我的jQuery脚本无法工作。我还需要一个人帮忙。我必须设置时间间隔,因为如果我输入一个字符,则直接显示可用。我必须在5秒后显示一条消息。那么我可以在哪里添加它呢?
$.ajax({
    type: "POST",
    url: "process.php",
    data: {email: name},//<--- Look here
    success: function(html){
        $("#status").html(html);
    }
});