Tiago Costa
Tiago Costa

Reputation: 4251

Changing web page content using Ajax

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

Answers (1)

poudigne
poudigne

Reputation: 1766

jquery ajax

$.ajax({
  url: "test.php",
  type: "POST",
  data : { var:'val1',var2:'val2' }
}).done(function() { 
  $("<div>").innerHTML("done");
});

Upvotes: 2

Related Questions