前言
GET
$.ajax({
url: "http://xxx/api/xxx",
success: function(ajaxData) {
console.log(ajaxData);
}
});
POST : form
$.ajax({
url: "http://xxx/api/xxx",
type: 'POST',
data: $('#form-id').serialize(),
success: function(ajaxData) {
console.log(ajaxData);
}
});
或者:
$.ajax({
url: "http://xxx/api/xxx",
type: 'POST',
data: {parentId: 0},
success: function(ajaxData) {
console.log(ajaxData);
}
});
POST : application/json
$.ajax({
url: "http://xxx/api/xxx",
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({parentId: 0}),
success: function(ajaxData) {
console.log(ajaxData);
}
});
|