Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- document.getElementById('latestNewsletterButton').addEventListener('click', function(event) {
- event.preventDefault(); // Prevent default action of the link
- // Make an AJAX request to fetch the latest newsletter link
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (xhr.readyState === XMLHttpRequest.DONE) {
- if (xhr.status === 200) {
- var latestNewsletterLink = xhr.responseText;
- // If request is successful, trigger the link
- window.location.href = latestNewsletterLink;
- // If request is successful, display the link
- } else {
- // If request fails, display an error message
- alert('Failed to fetch latest newsletter.');
- }
- }
- };
- xhr.open('GET', 'LatestNewsletter.php', true);
- xhr.send();
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement