Forum Moderators: open

Message Too Old, No Replies

Can you take a look at this AJAX for me?

Missing a closing Brace?

         

Seachmall

6:19 pm on Nov 2, 2007 (gmt 0)

10+ Year Member



This is my first Ajax script and I'm being told that I'm missing a closing brace. Heres my script:

var xmlHttp;
function getDays(){
xmlHttp = GetXmlHttpObject();
if (xmlHTTP==null){
alert ("Your Browser does not support Ajax");
return;
}
var url = "Apage.php";
url = url + "?ran" + Math.random();
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.send("number=" + getElementById('number').value);
}
///////////////////////////////////////////////////
function stateChanged(){
if(xmlHttp.readyState==4 ¦¦ xmlHttp.readyState=="complete"){
document.getElementById("days").innerHTML = xmlHttp.responseText;
}
}
//////////////////////////////////////////////////
function GetXmlHttpObject(){
var xmlHttp = null;
try{
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

Its an external script and this is the error message I'm getting:


missing } in XML expression (line 5);
xmlHttp = GetXmlHttpObject();
----------------------------^

As far as I can tell all braces have been closed so what am I doing wrong?

*The /// are replacing line breaks. For some reason the code tag cancels after a line break.*

mehh

5:27 pm on Nov 6, 2007 (gmt 0)

10+ Year Member



your calling GetXmlHTTPObject before its defined. move the function further up in the code.