首页 > 其他 > 详细

2016-04-21

时间:2016-04-22 06:58:49      阅读:235      评论:0      收藏:0      [点我收藏+]

今天是2016-04-21,也是我们学习Js的第十天。
今天我们完善了如何做二级菜单,表单提交,轮播和ajax。

☆ 二级菜单
需要注意的问题:1.float和position。
2.必要时增加图层。

☆ 表单提交
今天的内容主要是表单提交前的验证:
<form onsubmit="return 函数名()">
<input type="submit">
</form>
<script>
function 函数名() {
console.info(1);
return true;
}
</script>

☆ 轮播
1.自动转换
2.移进移出
3.向前向后
4.索引事件

☆ ajax
1.创建xhr
var xhr = null;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest(); ——→dom
} else {//ie
xhr = new ActiveXObject("Microsoft.XMLHTTP");——→ie
}

2.打开链接
(1)POST
xhr.open("POST", "newPage.html", true); ——→ true为异步
(2)GET
xhr.open("GET", "newPage.html", true);

可调用Json数据
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
3.绑定回调函数:发送成功之后触发
xhr.onreadystatechange = function() {
arr = JSON.parse(xhr.responseText); ——→获取Json数据(数组);
document.body.innerHTML = xhr.responseText;
};
4.发送请求
(1)POST
xhr.send("password=123&username=321");
(2)GET
xhr.send("null");

 

2016-04-21

原文:http://www.cnblogs.com/cjy2016/p/5419773.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!