--- id: 587d7fae367417b2b2512be3 title: Get JSON with the JavaScript XMLHttpRequest Method challengeType: 6 videoUrl: '' localeTitle: Получить JSON с помощью метода XMLHttpRequest JavaScript --- ## Description undefined ## Instructions
Обновите код для создания и отправки запроса «GET» в FreeCodeCamp Cat Photo API. Затем нажмите кнопку «Получить сообщение». Функция AJAX заменит текст «Сообщение будет здесь» с исходным выходом JSON из API.
## Tests
```yml tests: - text: '' testString: 'assert(code.match(/new\s+?XMLHttpRequest\(\s*?\)/g), "Your code should create a new XMLHttpRequest.");' - text: Ваш код должен использовать open метод для инициализации запроса «GET» в FreeCodeCamp Cat Photo API. testString: 'assert(code.match(/\.open\(\s*?("|")GET\1\s*?,\s*?("|")\/json\/cats\.json\2\s*?,\s*?true\s*?\)/g), "Your code should use the open method to initialize a "GET" request to the freeCodeCamp Cat Photo API.");' - text: '' testString: 'assert(code.match(/\.send\(\s*\)/g), "Your code should use the send method to send the request.");' - text: В вашем коде должен быть обработчик события onload установленный на функцию. testString: 'assert(code.match(/\.onload\s*=\s*function\(\s*?\)\s*?{/g), "Your code should have an onload event handler set to a function.");' - text: '' testString: 'assert(code.match(/JSON\.parse\(.*\.responseText\)/g), "Your code should use the JSON.parse method to parse the responseText.");' - text: Ваш код должен получить элемент с message класса и изменить его внутренний HTML на строку данных JSON. testString: 'assert(code.match(/document\.getElementsByClassName\(\s*?("|")message\1\s*?\)\[0\]\.innerHTML\s*?=\s*?JSON\.stringify\(.+?\)/g), "Your code should get the element with class message and change its inner HTML to the string of JSON data.");' ```
## Challenge Seed
```html

Cat Photo Finder

The message will go here

```
## Solution
```js // solution required ```