How to convert jQuery to JavaScript? -
i need convert code javascript:
$(function(){ $("#include_header").load("includes/header.html"); $("#include_footer").load("footer.html"); });
issue is, beginner javascript , can't figure out how... in javascript? it's jquery.
try sample:
window.addeventlistener('domcontentloaded', function() { console.log('window - domcontentloaded - capture'); var xhr = new xmlhttprequest(); //ajax request xhr.open('get', 'includes/header.html'); xhr.onload = function() { if (xhr.status === 200) { document.getelementbyid('include_header').innerhtml =xhr.responsetext; } else { alert('request failed. returned status of ' + xhr.status); } }; xhr.send(); //second request var xhr = new xmlhttprequest(); //ajax request xhr.open('get', 'footer.html'); xhr.onload = function() { if (xhr.status === 200) { document.getelementbyid('include_footer').innerhtml =xhr.responsetext; } else { alert('request failed. returned status of ' + xhr.status); } }; xhr.send(); }, true);
Comments
Post a Comment