I am trying to open the page in my tag. I have used following code.
Javascript:
function tempFunction() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
document.getElementById("page").innerHTML = xhr.response;
}
};
xhr.open("GET", "http://stackoverflow.com/", false);
xhr.send();
}
HTML:
<input type="button" id="btn" name="btn" value="Load" onclick="tempFunction()" />
<div id="page"></div>
Reference link: http://jsfiddle.net/DZmBG/3/
But when I tried by changing the URL to stackoverflow my code throw error:
Unhandled exception at line 49, column 13 in http://localhost:10642/WebForm2.aspx
0x800a139e - JavaScript runtime error: NetworkError
Is there any thing wrong am I doing?
Can any one help me to solve this?
Thank you in advance...!