ajax请求失败,新手请教思路,具体问题出在哪里
请求地址格式 http://study.163.com /webDev/login.htm
请求方式 get类型
请求参数 userName;
password;
请求参数说明 固定用户帐号:studyOnline ;
固定用户密码:study.163.com ;
使用Md5加密该用户数据 ;
返回 整型
返回数据说明 1 //匹配用户名密码成功
0 //匹配用户名密码失败
var oConfirm=document.getElementsByClassName("confirm-btn")[0];
oConfirm.onclick=function(){
var loginIn=new XMLHttpRequest();
loginIn.open("GET","http://study.163.com /webDev/login.htm",true);
var data="userName="+document.getElementsByClassName("login-name").value
+"&password="+document.getElementsByClassName("login-password").value;
loginIn.setRequestHeader("Content-type","application/x-www-form-urlencoded");
loginIn.send(data);
loginIn.onreadystatechange=function(){
if(loginIn.readyState==4&&loginIn.status==200){
var reData=JSON.parse(loginIn.responseText);
if(reData==1){
alert("登录成功");
setCookie(loginInto,success,new Date(2050,1,1));
document.getElementById("mask").style.display="none";
document.getElementById("login").style.display ="none";
}else if(reData==0){
alert("登录失败,用户名或密码错误");
}
}else{
alert("发生错误!");
}
}
}
http://study.163.com /webDev/login.htm
多了个空格导致域名无法解析把
ERR_NAME_NOT_RESOLVED