I am rendering a php script in my html with the jquery function load, so I want to use pure javascript now without the jquery library. Here is the code:
$(()=>{
$('#loadTable').load('./php/loadTable.php');
})
How can I achieve this using pure javascript?
Using fetch and Element.innerHTML:
fetch('./php/loadTable.php')
.then(resp => {
// TODO: add error handling
return resp.text();
})
.then(text => {
document.querySelector('#loadTable').innerHTML = text;
});