1// GET请求
2$.ajax({
3 type: "GET",
4 url: "url",
5 data: {
6 name: "xxx"
7 },
8 dataType: "json",
9 timeout: 300,
10 context: $("body"),
11 success: function (data) {},
12 error: function (xhr, type) {}
13});
14
15// POST 请求:需要通过JSON.stringify()将参数转化为JSON字符串
16$.ajax({
17 type: "POST",
18 url: "url",
19 data: JSON.stringify({
20 name: "xxx"
21 }),
22 success: function (data) {},
23 error: function (xhr, type) {}
24});