MyTube/public/js/ajax.js

21 lines
538 B
JavaScript
Raw Permalink Normal View History

2021-01-07 18:59:37 +00:00
function ajaxGet(url, callback) {
var http = new XMLHttpRequest();
http.open("GET", url, true);
http.onreadystatechange = function () {
if (http.readyState === 4) {
callback(http.responseText);
}
}
http.send(null);
}
function ajaxPost(url, data, callback) {
var http = new XMLHttpRequest();
http.open("POST", url, true);
http.onreadystatechange = function () {
if (http.readyState === 4) {
callback(http.responseText);
}
}
http.send(data);
}