With jQuery I can update the contents of a div I using $.load()
. How can I update a div in pure JavaScript?
As suggested by Julian H. Lam:
var req = new XMLHttpRequest();
req.open("POST", "address_for_div_content", true);
req.onreadystatechange = function () {
if (req.readyState != 4 || req.status != 200) return;
document.getElementById('id_of_div')=req.responseText;
};
Here the documentation for XMLHttpRequest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With