Mamy sobie kod:
<!DOCTYPE html>
<html>
<body>
<script>
function LadujZawartoscStronyURL(url) {
var req = new XMLHttpRequest();
req.open('GET', url, true);
req.send(null);
if(req.status == 200){
return req.responseText;
}else{
return null;
}
}
alert(LadujZawartoscStronyURL('https://www.google.pl'));
</script>
</body>
</html>
Pytanie, dlaczego ten kod nie działa, a powinien, i jak go poprawić? A powinien wyświetlić się alert ze źródłem strony!