1.$.ajax
$.ajax({
//type:"post",
url : "myServlet1.do",
cache : false,//关闭缓存
dataType : "text",
data : "username=张三&password=123",
success : function(data) {
alert(data);
},
error : function() {
alert("服务器崩溃了");
}
});
2.$.get方式
$.get(
"myServlet1.do",//请求的url
{"username":"lisi","password":"234","_",new Date().getTime()},//json传参
//"username=zs&password=123",//普通传参
function(data) {//请求成功回掉函数
alert(data);
},
"text"//返回值类型,常用"json"
);
3.$.post与get方式差不多