-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Javascript 3 #4
Conversation
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'); | ||
} |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В обоих случаях запросы отправятся параллельно
javascript/javascript-3_request.js
Outdated
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'); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Повторяющийся код и константа с параллельными запросами
changes according requests