XMLHttpRequest works for first url but it doesn't work for second url.I think this function doesn't work for dynamic web pages.I also tried ajax to get html source but it didn't work too.What can I do?How can I change this code to work for second url?
<script language="Javascript" type="text/javascript">
function getSource(url)
{
var req = new XMLHttpRequest();
req.open(
"GET",
url,
true);
req.onreadystatechange = statusListener;
req.send(null);
function statusListener()
{
if (req.readyState == 4)
{
if (req.status == 200)
{
var doc=req.responseText;
alert(doc);
}
}
}
}
url1 = "https://pages.github.com/";
url2 = "https://stackoverflow.com/";
// This code WORKS
getSource(url1);
// This code DON'T WORK
getSource(url2);
</script>