Load from the Server-Ajax

The first is to keep the templates remote and use an XMLHttpRequest object to retrieve
additional markup. This approach is more convenient for single-page applications than
for multiple-page applications.

For instance, clicking on a link that should bring up a
new dialog box might look like this:

function loadDialog(name, oncomplete) {
var xhr = new XMLHttpRequest();
xhr.open("get", "/js/dialog/" + name, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var div = document.getElementById("dlg-holder");
div.innerHTML = xhr.responseText;
oncomplete();
} else {
// handle error
}
};
xhr.send(null);
}