数据交互
1.send({params})
:向服务器发送ajax请求,需要服务器开启跨域权限。
参数params:
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
url | string | 不可为空 | 请求地址 |
type | string | get | 请求类型,取值范围:get/post/put/patch/delete |
data | json | {} | 请求数据 |
cache | boolean | false | 是否缓存 |
encode | boolean | false | 是否encode |
success | function | 成功回调函数 | |
error | function | 失败回调函数 |
示例:
t.send({
url: serverurl + "/comments/" + id,
type: "delete",
data: {},
success: function(data) {
if(data.state == "success") {
t(obj).parents("li").remove();
} else {
t.alert(data.message);
}
}
});