Hi, I’m trying to work out the simplest way to reuse AJAX in a project. This is what I have so far, would this work to reuse? //AJAX Variables var xhr = new XMLHttpRequest(); var _success = xhr.status == 200; //AJAX Error Message function no_msg(element){ document.querySelector(element).innerHTML = "Oops. We have encountered an error."; }; document.querySelector("#btn") .addEventListener('click', function(){ xhr; xhr.onload = function(){ if(_success){ h1.innerHTML = xhr.responseText; } else{ no_msg("#text"); } }; xhr.open("GET", "data.txt", true); xhr.send(); }); console.log(xhr); Code (JavaScript):