MyTube/public/js/ajax.js
2021-01-07 19:59:37 +01:00

21 lines
No EOL
538 B
JavaScript

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);
}