Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function submitPOST(elementId, api, callback) {
- let input = document.getElementById(elementId).getElementsByTagName("input");
- let body = {};
- for (let i = 0; i < input.length; i++) {
- body[input[i].name] = input[i].value;
- }
- call('POST', api, body, callback);
- xmlHttp.onload = function () {
- if (xmlHttp.status==200){
- callback(xmlHttp.response);
- }else{
- console.log(xmlHttp.response);
- }
- };
- xmlHttp.open(method, domainName+"/api/"+api, true); // true for asynchronous
- xmlHttp.setRequestHeader("Content-Type", "application/json");
- xmlHttp.send(JSON.stringify(body));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement