var items = { name: 'form_name', addr: 'form_addr', subj: 'form_subj', text: 'form_text', }; var server = getServer(); var xhrSend = new XMLHttpRequest(); var token = ""; var xhrToken = new XMLHttpRequest(); xhrToken.onreadystatechange = function() { if(xhrToken.readyState == XMLHttpRequest.DONE) { token = xhrToken.responseText; } } // Returns the server's base URI based on the user's script tag // return: the SMAM server's base URI function getServer() { var scripts = document.getElementsByTagName('script'); // Parsing all the