let request = obj => { return new Promise( (resolve, reject) => { let xhr = new XMLHttpRequest(); xhr.open(obj.method || "GET", obj.url); //xhr.open("GET", "../../cgi-bin/TI_2025/lab07/ajax_hello.py", true); xhr.onload = () => { if (xhr.status === 200) { console.log("Wynik połączenia:"); console.log(xhr.response); resolve (xhr.response) ; } else { reject (xhr.statusText); } }; xhr.onerror = () => reject (xhr.statusText); xhr.send(); }); } ; function sendRequest() { request( {url: "../../cgi-bin/TI_2025/lab07/ajax_hello.py" } ) .then ( data => { alert ( data ) ; }) .catch ( error => { console.log(error); }); }