Porl123 Posted April 7, 2010 Share Posted April 7, 2010 function ajaxCon() { var xmlhttp = false; if(window.XMLHttpRequest) { xmlhttp = XMLHttpRequest; } else { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } if(xmlhttp != 'false') { return xmlhttp; } } var xmlContent = ajaxCon(); if(xmlContent == false) { alert('Bad browser.'); } else { xmlContent.open('GET', 'http://www.google.com', true); xmlContent.send(); xmlContent.onreadystatechange = function() { if(xmlContent.readyState == 4) { alert(xmlContent.responseText); } } } Hi, I'm quite new to javascript/ajax and I'm not really sure why this isn't working. I just copied this from a few tutorials and edited it. What I want it to do is to get the contents of the page. I've just put in google as an example. Can anyone see where I've gone wrong? Thanks! Link to comment https://forums.phpfreaks.com/topic/197902-xml-http-requests/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.