看到题目要想到:
JQuery是什么东西?
是一个JavaScript类库,封装了大量的JavaScript底层代码。JQuery的Ajax操作
对JavaScript底层Ajax操作进行了封装,提供了两种方法进行操作
底层的$.ajax()操作
快捷操作$.get()..$.post()...
<script>
$.ajax({
url:"url", //接口地址
type:"get",
dataType:"json",
data:{ //数据
userID:"1"
},
success:function(response){
},
error:function() {
}
});
$.get(
"url",
{userID:"123"},
function(response) {
}
)
$.post(
"url",
{userID:"123"},
function(response) {
}
)
</script>
JQuery对JS ajax进行了封装,提供了$.ajax()底层操作,也是我们项目中使用最频繁的方法。
同时提供了$.get()..$.post()等快捷操作,方便我们进行请求的处理!