Skip to content

Commit

Permalink
[message]
Browse files Browse the repository at this point in the history
  • Loading branch information
xuechengjinxiu committed Dec 28, 2018
0 parents commit 854bce4
Show file tree
Hide file tree
Showing 167 changed files with 23,972 additions and 0 deletions.
46 changes: 46 additions & 0 deletions myAjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function myAjax(opt) {
opt = opt || {}; // ��·����� opt = opt && '3'
opt.method = opt.method || 'GET';
opt.url = opt.url || '';
opt.async = opt.async || true;
opt.data = opt.data || null;
opt.dataType = opt.dataType || 'JSON'
opt.success = opt.success || function () {
};
var xmlHttp = null;
if (XMLHttpRequest) {
xmlHttp = new XMLHttpRequest(); //��ie�����ajax����
}
else {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); //ie�µ�ajax����
}
var params = [];
for (var key in opt.data)params.push(key + '=' + opt.data[key]);
var postData = params.join('&');
if (opt.dataType === 'JSONP') {
creatScript(opt.url, postData);
} else {
if (opt.method.toUpperCase() === 'POST') {
xmlHttp.open(opt.method, opt.url, opt.async);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
xmlHttp.send(postData);
}
else if (opt.method.toUpperCase() === 'GET') {
xmlHttp.open(opt.method, opt.url + '?' + postData, opt.async);
xmlHttp.send(null);
}
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
if (opt.dataType === 'JSON') {
//JSON.parse(xmlHttp.response)
opt.success(xmlHttp.response);
}
}
};
}
}
function creatScript(url, data) {
var oScript = document.createElement('script');
oScript.src = url + '?' + data + '&callback=getEn';
document.body.appendChild(oScript);
}
Binary file added 上传模板/css/QQ截图20181110122001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 854bce4

Please sign in to comment.