Uplemented more logic
This commit is contained in:
24
public/js/custom.ts
Normal file
24
public/js/custom.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
const HTTP_BASE = "http://localhost:3000";
|
||||
|
||||
function httpGetAsync(theUrl, callback) {
|
||||
const xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.onreadystatechange = () => {
|
||||
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
|
||||
if (!!callback) {
|
||||
callback(xmlHttp.responseText);
|
||||
}
|
||||
}
|
||||
};
|
||||
xmlHttp.open("GET", theUrl, true); // true for asynchronous
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
|
||||
function sendAge(elem) {
|
||||
console.log(`age: ${elem.value}`);
|
||||
httpGetAsync(`${HTTP_BASE}/update/personal?age=${encodeURI(elem.value)}`, null);
|
||||
}
|
||||
|
||||
function sendSex(elem) {
|
||||
console.log("gender: " + elem.value);
|
||||
httpGetAsync(`${HTTP_BASE}/update/personal?sex=${encodeURI(elem.value)}`, null);
|
||||
}
|
||||
Reference in New Issue
Block a user