Cześć. Sorry za totalnie głupie pytanie ale jestem totalnie zielony jeśli chodzi o Javascript i AJAX.
Zrobiłem prostą stronkę na której w kontenerze manual, po kliknieciu w odnośnik ma się znaleść to, co dostępne jest poda daresem 127.0.0.1/manual
<------><http://december.com/html/4/element/script.html> <------> function updateManual() { <------><------>let manualContainer = document.getElementById("manual"); <------><------>fetch("http://127.0.0.1/manual") <------><------>.then(response => { <------><------> manualContainer.innerText = `${response}`; <------><------>}); <------> } <------></http://december.com/html/4/element/script.html> <http://december.com/html/4/element/a.html href="#" onClick="updateManual()">manual</http://december.com/html/4/element/a.html> <http://december.com/html/4/element/pre.html id="manual"> Tutaj ma się wczytać podręcznik </http://december.com/html/4/element/pre.html>
zajrzyj co zawiera response, a wszystko bedzie jasne....
console.log(response);
Nadal zdziwiony czemu nie dziala?
Tu masz przyklad jak sie dobrac do textu
https://stackoverflow.com/questions/40385133/retrieve-data-from-a-readablestream-object
a konkretnie
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(function(response) {
return response.text();
}).then(function(data) {
console.log(data); // this will be a string
});
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)