# AJAX

```javascript
let request = new XMLHttpRequest();
request.open("GET", "http://www.example.com/");
request.onreadystatechange = function () {
    if (this.readyState === 4 && request.status === 200) {
        let result = JSON.parse(request.responseText);
    }
};
request.send();
```

- open()
- setRequestHeader()
- responseType
    - attaybuffer
    - blob
    - document
    - json
    - text
- timeout
- onreadystatechange
    - UNSENT : 0
    - OPENED : 1
    - HEADERS_RECEIVED : 2
    - LOADING : 3
    - DONE : 4
- status, statusText
- send()
- response, responseText, responseURL, responseXML

```javascript
let request = new XMLHttpRequest();
request.open("POST", "http://www.example.com/");
request.responseType = "json";
request.onreadystatechange = function () {
    if (this.readyState === DONE && request.status === 200) {
        let result = request.response;
    }
};
request.send(JSON.stringify({message : "Hello"}));
```