Skip to content
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

Javascript 3 #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Javascript 3 #4

wants to merge 4 commits into from

Conversation

olga-pechatkina
Copy link
Owner

changes according requests

var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "http://127.0.0.1:3000", true);
xmlHttp.send(null);
http.get('http://127.0.0.1:3000');
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Повторяющийся код с :7

var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "http://127.0.0.1:3000", true);
xmlHttp.send(null);
http.get('http://127.0.0.1:3000');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В обоих случаях запросы отправятся параллельно

var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "http://127.0.0.1:3000", true);
xmlHttp.send(null);
http.get('http://127.0.0.1:3000');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Созданный Promise выполнит конструктор сразу, поэтому здесь происходят параллельные запросы. Если этот код для последовательных запросов, то не хватает логики для ожидания выполнения Promise

if(res!== undefined)
{
N--;
while (N>0) return request(N,type);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Довольно странная конструкция - для чего нужен while?

xmlHttp.open("GET", "http://127.0.0.1:3000", true);
xmlHttp.send(null);
})
http.get('http://127.0.0.1:3000', (res) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Повторяющийся код и константа с параллельными запросами

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants