Jump to content

XML Http Requests


Porl123

Recommended Posts

	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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.