function ajaxMethod(url, data) {
var ajax = new XMLHttpRequest();
ajax.open('post', url);
ajax.setRequestHeader("Content-type", "application/json;charset=UTF-8");
if (JSON.stringify(data)) {
ajax.send(JSON.stringify(data));
} else {
ajax.send();
}
ajax.onreadystatechange = function () {
if (ajax.readyState == 4 && ajax.status == 200) {
console.log(ajax.responseText);
return ajax.responseText;
}
}
};
$.ajax({
url: '',
type: 'post',
data: { },
dataType: 'json'
}).then(function (res) {
console.log(res, 444);
}).fail(function () {
console.log('失败');
})