first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
class HTTP {
constructor() {
}
get(option) {
return new Promise((success, error) => {
$.ajax({
type: "GET",
url: config.checkUrl() + option.url,
data: option.data,
success: (msg) => {
this.onreadystatechange(success, error, msg)
}
});
})
}
post(option) {
return new Promise((success, error) => {
$.ajax({
type: "POST",
url: config.checkUrl() + option.url,
data: option.data,
success: (msg) => {
this.onreadystatechange(success, error, msg)
}
});
})
}
onreadystatechange(success, error, res) {
switch (res.status) {
case 200:
return success(res.result)
break;
case 404:
alert(res.message);
throw new Error(res.message);
break;
}
}
}