Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- button.addEventListener('click', (event) => {
- event.preventDefault();
- fetch(`https://example.com/api.php?part=${partId}`)
- .then(function (response) {
- return response.json();
- })
- .then(function (jsonRes) {
- console.log(JSON.stringify(jsonRes));
- if (jsonRes.part.partFound == true) {
- console.log('Found! Processing...');
- // REMOVE preventDefault() and process
- } else {
- console.log('Not found! Aborting...', partId);
- }
- });
Add Comment
Please, Sign In to add comment