开发者学堂课程【Ajax 前端开发入门与实战:案例02_验证邮箱唯一性】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/595/detail/8526
案例02_验证邮箱唯一性
邮箱唯一性的验证
email.onblur = function()f
var emailValue = email.value;
var xhr = null;
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
} else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
var param ="e="
emailValue;
xhr.open("post","./server/checkEmail.php",true);
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.send(param);
xhr.onreadystatechange
function()f
if(xhr.readyState4){
if(xhr.status
200){
var result = xhr.responseText;
var email_result =
document.querySelector("#email_result");
if(result
//邮箱可用
email_result.innerText ="邮箱可以使用";
} else {
email_result.innerText =“邮箱不可以使用";