报错了请老师给看下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>登录验证</title>
<link rel="stylesheet" href="./CSS/style.css">
</head>
<body>
<div class="register">
<p class="title">
<span>登 录</span>
<span class="current">注册</span>
</p>
<div class="form">
<div>
<span>+86</span>
<input type="text"name="user" id="user" placeholder="请输入注册手机号" autocomplete="off">
<i></i>
<p class="info"></p>
</div>
<div>
<input type="password" name="password" id="password" placeholder="请设置密码">
<i></i>
<p class="info"></p>
</div>
<p class="button">
<a href="javascript:void(0)" id="btn" class="btn">注册</a>
</p>
</div>
</div>
</body>
<!-- <script type="text/javascript" src="./JS/ajax.js"></script> -->
<script type="text/javascript">
var $={
ajax:function(arguments){
var xhr=null,
url = arguments.url,
method=arguments.method ||'get',
async= typeof(arguments.async)=='undefined'?true:arguments.async,
data=arguments.data ||null,
params='',
callback=arguments.success,
error=arguments.error;
//将data的对象字面的形式转换为字符串
if(data){
for(var i in data){
params += i + '=' +data[i]+'&';
}
params=params.replace(/&$/,'')
}
if(method==='get'){
url+='?'+params;
}
if(typeof XMLHttpRequest!=='undefined'){
xhr= new XMLHttpRequest();
}else if(typeof ActiveXObject!=='undefined'){
var xhrArr=['Micorsoft.XMLHTTP','MSXML2.XMLHTTP.6.0'
,'MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0',
'MSXML2.XMLHTTP.2.0'];
for(k in xhrArr){
try{
xhr=new ActiveXObject(xhrArr[k]);
break;
}catch(e){
}
}
return xhr;
}else{
throw new Error('NO XHR object availabel')
}
xhr.onreadystatechange=function(){
if(xhr.readyState===4){
if((xhr.status >=200 && xhr.status<300)||xhr.status==304){
console.log(xhr.responseText)
callback && callback(JSON.parse(xhr.responseText))
}else{
error && error()
}
}
}
xhr.open(method,url,async);
xhr.setRequestHeader('Content-type','application/x-www-form-urlcoded');
xhr.send(params)
}
}
$.ajax({
url:'http://127.0.0.1/registser.php',
method:'post',
async:true,
data:{username:12312321321,passwd:1231231231},
dataType:JSON,
success:function(){},
error:function(){}
})
</script>
</html>
正在回答
同学你好,老师上次回复的时候说,改成的是自己本地的地址测试的,但是同学文件存放地址与老师的不一定相同,所以不要直接使用老师的地址,只是建议同学把自己地址中的127.0.0.1改成localhost哦。这个报错就是路径找不到,如果不对,建议自己检查本地的文件路径是否一致哦。
祝学习愉快~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星