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,36 @@
/**
*
* @param {*} params
* {
* method: '' // 请求方法
* url: '' //请求网址
* success: function(){}
* }
*/
function http(params) {
var http = new XMLHttpRequest();
var par = ""
if (params.hasOwnProperty("data")) {
for (const key in params.data) {
par+=`&${key}=${params.data[key]}`
}
params.url = params.url + par.replace("&", "?")
}
http.open(params.method, params.url);
http.send();
http.onreadystatechange = function () {
if (http.readyState == 4 ) { // 浏览器自带的
if (http.status == 200) { // 浏览器自带的
var res = JSON.parse(http.responseText);
if (res.reason == "Success") {
params.success(res)
} else {
params.error(res)
}
} else {
alert("网络不好")
}
}
}
}