Skip to content

XMLHttpRequest #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
340 changes: 169 additions & 171 deletions 5-network/08-xmlhttprequest/article.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 5-network/08-xmlhttprequest/example.view/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function accept(req, res) {



// ----- запуск accept как сервера из консоли или как модуля ------
// ----- avvia il server ------

if (!module.parent) {
http.createServer(accept).listen(8080);
Expand Down
4 changes: 2 additions & 2 deletions 5-network/08-xmlhttprequest/phones-async.view/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var file = new static.Server('.', {
function accept(req, res) {

if (req.url == '/phones.json') {
// искусственная задержка для наглядности
// va un pochino in stallo per permettere di mostrare il messaggio di "loading"
setTimeout(function() {
file.serve(req, res);
}, 2000);
Expand All @@ -21,7 +21,7 @@ function accept(req, res) {
}


// ------ запустить сервер -------
// ------ avvia il server -------

if (!module.parent) {
http.createServer(accept).listen(8080);
Expand Down
4 changes: 2 additions & 2 deletions 5-network/08-xmlhttprequest/phones.view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
xhr.send();

if (xhr.status != 200) {
// handle error
// gestisce l'errore
alert('Error ' + xhr.status + ': ' + xhr.statusText);
} else {
// show result
// mostra il risultato
alert(xhr.responseText);
}
}
Expand Down
4 changes: 2 additions & 2 deletions 5-network/08-xmlhttprequest/phones.view/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let file = new static.Server('.', {
function accept(req, res) {

if (req.url == '/phones.json') {
// stall a bit to let "loading" message show up
// va un pochino in stallo per permettere di mostrare il messaggio di "loading"
setTimeout(function() {
file.serve(req, res);
}, 2000);
Expand All @@ -21,7 +21,7 @@ function accept(req, res) {
}


// ------ запустить сервер -------
// ------ avvia il server -------

if (!module.parent) {
http.createServer(accept).listen(8080);
Expand Down
4 changes: 2 additions & 2 deletions 5-network/08-xmlhttprequest/post.view/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function accept(req, res) {
chunks.push(data);
length += data.length;

// More than 10mb, kill the connection!
// Per un contenuto maggiore di 10mb, termina la connessione!
if (length > 1e8) {
req.connection.destroy();
}
Expand Down Expand Up @@ -49,7 +49,7 @@ function accept(req, res) {
}


// ------ запустить сервер -------
// ------ avvia il server -------

if (!module.parent) {
http.createServer(accept).listen(8080);
Expand Down