Skip to content

Commit d79c761

Browse files
committed
fixes
1 parent a6552eb commit d79c761

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

5-network/07-xmlhttprequest/article.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ In modern web-development `XMLHttpRequest` may be used for three reasons:
1414

1515
Does that sound familiar? If yes, then all right, go on with `XMLHttpRequest`. Otherwise, please head on to <info:fetch-basics>.
1616

17-
## Basic flow
17+
## The basics
1818

1919
XMLHttpRequest has two modes of operation: synchronous and asynchronous.
2020

2121
Let's see the asynchronous first, as it's used in the majority of cases.
2222

2323
To do the request, we need 3 steps:
2424

25-
1. Create `XMLHttpRequest`.
25+
1. Create `XMLHttpRequest`:
2626
```js
27-
let xhr = new XMLHttpRequest(); // no arguments
27+
let xhr = new XMLHttpRequest(); // the constructor has no arguments
2828
```
2929

30-
2. Initialize it.
30+
2. Initialize it:s
3131
```js
3232
xhr.open(method, URL, [async, user, password])
3333
```
3434

35-
This method is usually called first after `new XMLHttpRequest`. It specifies the main parameters of the request:
35+
This method is usually called right after `new XMLHttpRequest`. It specifies the main parameters of the request:
3636

3737
- `method` -- HTTP-method. Usually `"GET"` or `"POST"`.
3838
- `URL` -- the URL to request.
@@ -203,7 +203,7 @@ xhr.onreadystatechange = function() {
203203
};
204204
```
205205

206-
You can find `readystatechange` listeners in really old code, for historical reasons.
206+
You can find `readystatechange` listeners in really old code, it's there for historical reasons, as there was a time when there were no `load` and other events.
207207
208208
Nowadays, `load/error/progress` handlers deprecate it.
209209
@@ -257,7 +257,7 @@ There are 3 methods for HTTP-headers:
257257
Several headers are managed exclusively by the browser, e.g. `Referer` and `Host`.
258258
The full list is [in the specification](http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method).
259259
260-
XMLHttpRequest is not allowed to change them, for the sake of user safety and correctness of the request.
260+
`XMLHttpRequest` is not allowed to change them, for the sake of user safety and correctness of the request.
261261
```
262262
263263
````warn header="Can't remove a header"
@@ -325,7 +325,7 @@ let formData = new FormData([form]); // creates an object, optionally fill from
325325
formData.append(name, value); // appends a field
326326
```
327327
328-
Create it, optionally from a form, `append` more fields if needed, and then:
328+
We create it, optionally from a form, `append` more fields if needed, and then:
329329
330330
1. `xhr.open('POST', ...)` – use `POST` method.
331331
2. `xhr.send(formData)` to submit the form to the server.
@@ -373,19 +373,19 @@ xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
373373
xhr.send(json);
374374
```
375375
376-
The `.send(body)` method is pretty omnivore. It can send almost everything, including Blob and BufferSource objects.
376+
The `.send(body)` method is pretty omnivore. It can send almost everything, including `Blob` and `BufferSource` objects.
377377
378378
## Upload progress
379379
380380
The `progress` event only works on the downloading stage.
381381
382-
That is: if we `POST` something, `XMLHttpRequest` first uploads our data, then downloads the response.
382+
That is: if we `POST` something, `XMLHttpRequest` first uploads our data (the request body), then downloads the response.
383383
384-
If we're uploading something big, then we're surely more interested in tracking the upload progress. But `progress` event doesn't help here.
384+
If we're uploading something big, then we're surely more interested in tracking the upload progress. But `xhr.onprogress` doesn't help here.
385385
386386
There's another object `xhr.upload`, without methods, exclusively for upload events.
387387
388-
Here's the list:
388+
The event list is similar to `xhr` events, but `xhr.upload` triggers them on uploading:
389389
390390
- `loadstart` -- upload started.
391391
- `progress` -- triggers periodically during the upload.
@@ -458,6 +458,8 @@ xhr.open('POST', 'http://anywhere.com/request');
458458
...
459459
```
460460
461+
See the chapter <info:fetch-crossorigin> for details about cross-origin headers.
462+
461463
462464
## Summary
463465
@@ -468,7 +470,7 @@ let xhr = new XMLHttpRequest();
468470
469471
xhr.open('GET', '/my/url');
470472
471-
xhr.send(); // for POST, can send a string or FormData
473+
xhr.send(); s
472474
473475
xhr.onload = function() {
474476
if (xhr.status != 200) { // HTTP error?

9-regular-expressions/09-regexp-groups/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,6 @@ Parentheses groups are numbered left-to-right, and can optionally be named with
237237

238238
The content, matched by a group, can be referenced both in the replacement string as `$1`, `$2` etc, or by the name `$name` if named.
239239

240-
So, parentheses groups are called "capturing groups", as they "capture" a part of the match. We get that part separately from the result.
240+
So, parentheses groups are called "capturing groups", as they "capture" a part of the match. We get that part separately from the result as a member of the array or in `.groups` if it's named.
241241

242242
We can exclude the group from remembering (make in "non-capturing") by putting `?:` at the start: `(?:...)`, that's used if we'd like to apply a quantifier to the whole group, but don't need it in the result.

0 commit comments

Comments
 (0)