Advertisement
lemansky

Untitled

Apr 26th, 2022
1,324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.61 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Document</title>
  8.     <script>
  9.         document.addEventListener('DOMContentLoaded', () => {
  10.             let data = [{"id": 1, "name": "Иван Иванов", "email": "pereinar@optonline.net", "phone": "12345344", "title": "Мениджър"},
  11.                 {"id": 2, "name": "Мария Петрова", "email": "juliano@aol.com", "phone": "368938736", "title": "Програмист"},
  12.                 {"id": 3, "name": "Стефан Колев", "email": "jipsen@outlook.com", "phone": "866893", "title": "Финансов директор"},
  13.                 {"id": 4, "name": "Петя Илиева", "email": "rasca@msn.com", "phone": "10237129", "title": "Бодигард"},
  14.                 {"id": 5, "name": "Деница Филева", "email": "mahbub@att.net", "phone": "0739483", "title": "Офис сътрудник"}];
  15.            
  16.             let btn = document.querySelector('#button');  
  17.             btn.addEventListener('click', () => {
  18.                 fetch('/api.js', {
  19.                     method: 'POST',
  20.                     headers: {
  21.                         'Accept': 'application/json, text/plain, */*',
  22.                         'Content-Type': 'application/json'
  23.                     },
  24.                         body: JSON.stringify(data)
  25.                     });
  26.             });
  27.         });
  28.     </script>
  29. </head>
  30. <body>
  31.     <button id="button">Click</button>
  32. </body>
  33. </html>
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement