1.Ajax的原生写法
说明: 原生ajax写法 $.ajax写法 jQuery的编程特点:函数式编程
$.ajax({
url : "/findAjax",
type : "get",
// data : {
// "id" : 100,
// "name" : "瞄"
// }
data:"id=100&name=瞄",
success:function(result){
alert("请求成功!!!")
for(let user of result){
let id = user.id;
let name = user.name;
let age = user.age;
let sex = user.sex;
let tr="<tr align='center'><td>"+id+"</td><td>"+name+"</td><td>"+age+"</td><td>"+sex+"</td></tr>"
$("#tab1").append(tr);
}
},
error:function(result){
alert("请联系管理员")
},
cache:true ,//默认值true 代表使用缓存
async : true //默认值 true 异步操作 false 代表同步操作
});
参数(data)写法:
第一种 “key” : "value " :
data: {
"id" : 100,
"name" : "瞄"
}
第二种:
data:"id=100&name=瞄"