码迷,mamicode.com
首页 > 其他好文 > 详细

2016-04-21

时间:2016-04-22 07:01:53      阅读:126      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!