Teensweb
New Member
- Messages
- 352
- Reaction score
- 1
- Points
- 0
I have an ajax code which fetches a page to a division. It is as follows:
fetcher.js-
Html-
It works fine, but the problem is that it won't fetch any remote url's that is, if I give http://google.com or something, it won't work.
Can u give a solution?
fetcher.js-
Code:
function fetch(URL, divId) {
req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
req.open("GET", URL, true);
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
document.getElementById(divId).innerHTML = req.responseText;
}
}
req.send(null);
}
HTML:
<script language="javascript" src="fetcher.js"></script>
<div id="container_div" class="container">Some default text<div>
<a href="#" onclick="fetch('somepage.php')">fetch</a>
Can u give a solution?