JavaScript AJAX Basics (retiring) AJAX Concepts A Simple AJAX Example

Martin Park
Martin Park
12,792 Points

Resolving this using fetch()

At the end of the fetch workshop. Guil suggests retracing your steps and using fetch() to complete these earlier workshops.

In case this helps anyone out there, the following code gets the same results using fetch():

<script>    

 fetch('sidebar.html')
  .then(response => response.text())
  .then(response => sendAJAX = () =>{
    document.getElementById('ajax').innerHTML = response;
    document.getElementById('load').style.display = "none";
  })

</script>
Steven Parker
Steven Parker
172,046 Points

:information_source: For those interested in "fetch" who find this through the AJAX course,
    the separate fetch workshop mentioned here is Working with the Fetch API.