什么是ajax,以及使用

1.Ajax技术合成 异步的JavaScript and xml css 资源

2.异步请求和局部刷新。
同步请求:等待第一个请求响应数据回发回来后,再发送第二次请求。
$.ajax(是否异步)

3.Ajax怎么运作? 一把枪 谁?js驱动这把枪
原生态Ajax核心对象:
判定当前的浏览器引擎有没有哪个对象? 能力检查 (情况1:IE 和非IE chrome和FireFox)
1.构建核心对象 XmlHttpRequest xhr;


2.设置他的属性和方法
xhr.open("post","/FirstServlet",true);
xhr.onreadystatechange=funtion(){
if(xhr.readyState==4&&xhr.status==200){
}

};

你要想发送Post请求,必须得有Content-Type
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.send(get:null/post:data);

4.使用jQuery实现Ajax
function newAjax() {
$.ajax({
url:"/FirstServlet",
type:"POST",
data:{"uname":$("[name=uname]").val()},
async:true,
success:function (data) {
$("#msg").html(data);
}
});
}

传统Web与Ajax的区别:

原文地址:https://www.cnblogs.com/hsa521/p/7678464.html