I've tried searching for a solution to this problem, but it's quite tricky when I get absolutely no error!

I had a working script that used Ajax to get an up to date rating from a php file. I'm in the process of upgrading my site to HTML5 and the script stopped working. The only error I would get was in Firefox Web Developer Web Console stating the line where the error was occuring. It gave absolutely no error message or reference besides that. I wasn't sure if Ajax worked slightly differently in HTML5, so I've used a different script (below), but it still gives the same blank error.

Can anyone see what I'm doing wrong? The PHP file definitely exists and returns valid data when accessed directly.

The blank error references the following line:
arequest.open('GET','userrating.php?h=' + h,true);
function ajaxRequest(){
	var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
		for(var i = 0; i < activexmodes.length; i++){
			try {
				return new ActiveXObject(activexmodes[i]);
			} catch(e){
				//suppress error
	} else if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	} else {
		return false;

function resetRating(h){
	var arequest = new ajaxRequest();
	arequest.onreadystatechange = function(){
		// do something
	var h = encodeURIComponent(h);
	arequest.open('GET','userrating.php?h=' + h,true);
Thanks, Ian