在提交之前检查电子邮件不起作用

时间:2016-06-01 10:57:02

标签: javascript ajax

如何查看是否已收到电子邮件?我找到了一个脚本,但它只显示"检查.."如果电子邮件存在,我无法得到确切的结果。下面你有代码:

String signUpText = mPreferenceData.getStoreInPreference("signup");
//now you will have data in signupText
button.setOnClickListener(new View.OnClickListener(){        
    if(loginText.getText().toString().trim().equalsIgnoreCase(signUpText)){
        // now loginText whatever data that matches with signUpText will make to login successful
    } else{
        //failure
    }

});

name_check.php

<span id="usernamestatus"></span> 
<input type="text" onblur="checkusername()" id="sign_up_email_input_first" name="email_sign_up" placeholder="E-Mail">

        function checkusername() {
                var status = document.getElementById("usernamestatus");
                var u = document.getElementById("sign_up_email_input_first").value;
                if ( u !="") {
                    status.innerHTML = 'checking...';
                    var hr = new XMLHttpRequest();
                    hr.open("POST", "name_check.php", true);
                    hr.setRequestHeader("Content-type", "application/x-www-form-urlendcoded");
                    hr.onreadystatechange = function(){
                        if (hr.readyState == 4 && hr.status ==200) {
                            status.innerHTML = hr.responseText;
                        }
                    }
                    var v = "name2check="+u;
                    hr.send(v);
                }
            }

2 个答案:

答案 0 :(得分:1)

在您的PHP文件中,替换

$_POST['sign_up_email_input_first']

with:

$_POST['email_sign_up']

你基本上用名字而不是id的

来获取值

答案 1 :(得分:0)

您没有提交表格。您只是将数据发送到name_check.php,并使用字段名称&#39; u&#39;作为xmlhttprequest

尝试在您的php文件中使用$_POST['u']代替$_POST['sign_up_email_input_first']