ajax 封装
作者:
一爷之秋 | 来源:发表于
2019-10-17 15:18 被阅读0次export request = function(url, method, success, fail) {
let ajax = null;
if (window.XMLHttpRequest) {
ajax = new XMLHttpRequest();
} else {
ajax = new ActiveXObject('Microsoft.XMLHTTP');
}
ajax.onreadystatechange = function() {
if (ajax.readyState === 4 && ajax.status === 200) {
success && success(ajax.responseText);
} else {
fail && fail();
}
};
ajax.open(method, url, true);
ajax.send();
}
本文标题:ajax 封装
本文链接:https://www.haomeiwen.com/subject/brtvmctx.html
网友评论