Reputation: 4251
I'm looking for the best way to dynamically update a web page content using Javascript AJAX.
My first thought is to store various div
layouts each describing a different page in various files, for example:
BasicDiv.div:
<div>
<p>Some Text</p>
<button> A Button </button>
</div>
-Then create an empty div
,which content will be updated, inside the main webpage, then I make a XMLHttpRequest
and update the div.innerHtml
with the data loaded from the required file.
Is this a good way to use AJAX or do you have a better suggestion?
Upvotes: 0
Views: 1340
Reputation: 1766
jquery ajax
$.ajax({
url: "test.php",
type: "POST",
data : { var:'val1',var2:'val2' }
}).done(function() {
$("<div>").innerHTML("done");
});
Upvotes: 2