View Single Post
Old 03-24-2006, 10:49 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
are you running the page locally? there could be a browser security issue. make sure the files are uploaded to the server. i just tested this code and it works.

test.html
HTML Code:
["First Song","Second Song"]
mypage.html
HTML Code:
<script language="javascript">
var my_songs = new Array();

// start ajax stuff
var xmlHttp;

function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
}

function startRequest(method, URL) {
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.open(method, URL, true);
	xmlHttp.send(null);
}

function handleStateChange() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			processResponse(xmlHttp.responseText);
		}
	}
}

function processResponse(response) {
	my_songs = eval(response);
	
	for( x in my_songs ) {
		alert( my_songs[x] );
	}
}

// make ajax request
startRequest('GET', 'test.html');
</script>
sde is offline   Reply With Quote