今天完成的事情:
今天开始写了页面

var oAjax = new XMLHttpRequest();
oAjax.open('GET', url, true);
oAjax.send();
oAjax.onreadystatechange = function(){
if (oAjax.readyState === 4){
if (oAjax.status === 200){
console.log(oAjax.responseText);
} else {
console.error(oAjax.statusText);
}
}};
一共分为4个步骤,创建对象,连接服务器,发送数据,接收收据
//IE9+
var aValue = document.getElementsByTagName('input');
var oMsg = document.getElementById('msg');
var oBtn = document.getElementById('btn');
var timer = null;
oBtn.onclick = function(event) {
event.preventDefault();
var name = aValue[0].value;
var pwd = aValue[1].value;
var data = "name=" + name + "&pwd=" + pwd;
var oAjax = new XMLHttpRequest();
oAjax.onreadystatechange = function() {
if (oAjax.readyState == 4 && oAjax.status == 200) {
var resdata = JSON.parse(oAjax.responseText);
console.log(name);
console.log(pwd);
console.log(resdata);
if (resdata.code === 0) {
window.location.href = "http://dev.admin.carrots.ptteng.com/";
} else {
clearInterval(timer);
oMsg.innerHTML = resdata.message;
timer = setTimeout(function() {
oMsg.innerHTML = '';
}, 3000)
}
}
}
oAjax.open('POST', '/carrots-admin-ajax/a/login', true);
oAjax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
oAjax.send(data);
}
明天计划的事情:
明天继续js5,把相关基础再巩固一下
另外使用jq把js5再写一遍
遇到的问题:
nginx配置,里面端口,域名等修改后,结果页面就打不开了
也不知道什么原因,索性就使用默认的了。。。
收获
js5任务js原代码完成
评论