Advertisement
Guest User

Part of ajax

a guest
Apr 8th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $.ajax({
  2.     method: "POST", // GET | POST | PUT | DELETE ...
  3.     body: JSON.stringify({/* Сюда тело */}), // При GET удалить строчку
  4.     url: "http://localhost:5050/api/users",
  5.     headers: {Authorization: "ТОКЕН", "Content-Type": "application/json"}, // Authorization можно удалить, если не нужен
  6.     success: (data, status, request) => {
  7.         /* data - возвращаемое сервером,
  8.            status - текст статуса,
  9.            request.status - число-статус */
  10.     },
  11.     error: (request, status, error) => {
  12.         /* request.status - число-статус,
  13.            status - текст статуса,
  14.            error - сама ошибка */
  15.     }
  16. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement