Question

My codes are

var myurl = "http://domain.tld/document.html";
var mydocument = myurl.document;
var mydiv = document.getElementById("mydiv");
mydiv.write = mydocument;

and

<div style="height:100%;width:100%" id="mydiv"></div> 

I do not want to use jQuery! My page have to include the page http://domain.tld/document.html in the div with id mydiv and I want know what is wrong?

Was it helpful?

Solution

If you want to do an ajax call with XMLHttpRequest() there is a pre html5 method and post html5 method. pre HTML5 does not support the onload event for XMLHttpRequest().

var xhr = new XMLHttpRequest();
xhr.open('Get', '/table1.php', true);

     /* html5 */ 
    xhr.onload = function(e) {/* script to process data here: data = xhr.response  */ 
          mydiv.innerHTML = xhr.response; 
    }
xhr.send();

Because of differences jquery ajax is much easier.

Pre HTML5 tutorial on XMLHttpRequest http://www.cristiandarie.ro/asp-ajax/Async.html

You can not use AJAX to process an HTML page from a different domain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top