第04章 $.ajax

102 阅读1分钟

参考:

  1. api.jquery.com/category/aj…
  2. jquery.cuishifeng.cn/jQuery.Ajax…

1. 下载安装

2. GET

$.ajax({
    url: "http://192.168.0.22:8888/info",
    dataType: "json"
}).done(res => {
    console.log(res);
}).fail(err => {
    console.log(err);
});

3. POST

$.ajax({
    url: "http://192.168.0.22:8888/login",
    type: "POST",
    dataType: "json",
    data: {
        username: "admin",
        password: "123"
    }
}).done(res => {
    console.log(res);
}).fail(err => {
    console.log(err);
});