Guest User

Untitled

a guest
Dec 10th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. button.addEventListener('click', (event) => {
  2. event.preventDefault();
  3. fetch(`https://example.com/api.php?part=${partId}`)
  4. .then(function (response) {
  5. return response.json();
  6. })
  7. .then(function (jsonRes) {
  8. console.log(JSON.stringify(jsonRes));
  9. if (jsonRes.part.partFound == true) {
  10. console.log('Found! Processing...');
  11. // REMOVE preventDefault() and process
  12. } else {
  13. console.log('Not found! Aborting...', partId);
  14. }
  15. });
Add Comment
Please, Sign In to add comment