Add carrack.js on static

This commit is contained in:
Dita Aji Pratama 2025-03-09 12:50:47 +07:00
parent a329f6b71b
commit 4dac4d439c

18
static/js/carrack.js Normal file
View File

@ -0,0 +1,18 @@
function sendHttpRequest(url, method, data, callback, contentType = "multipart/form-data") {
var xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.setRequestHeader("Content-Type", contentType);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var response = xhr.responseText;
callback(null, response);
}
else callback(xhr.status, null);
}
};
var requestData;
if (contentType === "application/json") requestData = JSON.stringify(data);
else requestData = data;
xhr.send(requestData);
}