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,97 @@
/**
* 1: ajax封装实现 1
*/
function get(url, callback) {
var http;
http = new XMLHttpRequest();
http.open("GET",url, true);
http.send();
http.onreadystatechange = function () {
if(http.readyState == 4) {
callback(JSON.parse(http.responseText))
}
}
}
/**
* 2: ajax封装实现 2
*/
// (function (win) {
// var $ = function () {},
// http = null;
//
// // 向方法 $ 中追加一个方法 init用来初始化ajax请求
// $.init = function () {
// http = new XMLHttpRequest();
// }
//
// // 向方法 $ 中追加一个方法 get用来发送get请求
// $.get = function (url, callback) {
// $.init()
// http.open("GET",url, true);
// http.send();
// http.onreadystatechange = function () {
// if(http.readyState == 4) {
// callback(http.responseText)
// }
// }
//
// }
// win.$ = $;
// })(window)
/**
* 2: ajax封装实现 2 精简版
*/
// (win => {
// var $ = () => {}, http = null;
//
// // 向方法 $ 中追加一个方法 init用来初始化ajax请求
// $.init = () => http = new XMLHttpRequest();
//
// // 向方法 $ 中追加一个方法 get用来发送get请求
// $.get = (url, callback) => {
// $.init()
// http.open("GET",url, true);
// http.send();
// http.onreadystatechange = () => http.readyState == 4 ? callback(http.responseText) : callback('noData')
// }
// win.$ = $;
// })(window)
// function f(a,b) {
// var result = a + 100;
//
// b(result)
// }
//
// function f1() {
// f(1,function (data) {
// console.log(data)
// } )
// }
//
//