លំហាត់​អនុវត្តន៍​អំពី AJAX

សំណួរ

១. តើ AJAX ជា​អ្វី​?
២. អ្វី​ទៅ​ជា HTTP
៣. តើ​សំណើរ​ប្រភេទ GET និង POST ខុស​គ្នា​ដូចម្តេច​ខ្លះ?

លំហាត់​អនុវត្តន៍

Task 1

Implement a web page “Catalogue of Copywriters”
The user opens the page and sees the names of all available copywriters displayed. Get data using the AJAX request taken from JSONPlaceholder.

Algorithm for getting the user list:
  1. Send the GET request at https://jsonplaceholder.typicode.com/users.
  2. Get a response in the JSON format. The response is an array consisting of 10 users.
  3. Parse these data and write them in the collection of objects of the User data type.
  4. Create HTML elements and add them to DOM.

When the copywriter is selected, their detailed information and the Show posts button are displayed below.

In order to get a detailed information, send the request to the same address https://jsonplaceholder.typicode.com/users, but this time add an id parameter with the required value. As a result, the address will look as follows: https://jsonplaceholder.typicode.com/users?id=2, or the short version: https://jsonplaceholder.typicode.com/users/2.


Clicking on the Show posts button outputs all posts of the selected copywriter. You can get a list of posts by sending a request to https:// jsonplaceholder.typicode.com/posts with the userId parameter specified.


Link to JSONPlaceholder: https://jsonplaceholder.typicode.com/. Link to an alternative API with users (in case JSONPlaceholder doesn’t work): https://reqres.in/.

If this API doesn’t work either, you will have to find another available resource on your own and adjust your task.