Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error in code

Status
Not open for further replies.

seanybravo

IS-IT--Management
Sep 24, 2003
89
GB
Could someone please help me find the syntax error in this cod I have been looking tat it for the last 4 hours and am unable to work it out:

var xmlHttp

function stateChanged2(obj,id){
document.getElementById(id).innerHTML=obj.responseText
}

function GetXmlHttpObject(URL, handler, id, strSend) {

alert("HELLO")

var objXmlHttp=null

try {objXmlHttp = new XMLHttpRequest();
}
catch(e){
try{objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{objXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){alert("error opening XMLHTTP")
}
}
}

objXmlHttp.onreadystatechange=function(){
if (objXmlHttp.readyState==4 || objXmlHttp.readyState=="complete"){
handler(objXmlHttp, id)
}
}

xmlHttp.open("POST",URL,true)
xmlHttp.setRequestHeader("Content-Type", "application/x- xmlHttp.send(strSend)
}


The HLML BIT

<input name="radiobuttonCustomData" type="radio" onclick="GetXmlHttpObject("Ajax.asp", stateChanged2, "CustomRecords", "Load=true")" value="true" />
 
I think there's a {} problem. Try indenting the code, you will se things clearer.

Cheers,
Dian
 
Thanks for you reply.

The problem seams to be with the GetXmlHttpObject function. I have checked the {} and still cant solve the error. Any other suggestions would be great.

 
You didn't check it OK, you miss a } to close the function.

Cheers,
Dian
 
Solved it

It was to do with the call from the in click event using " insted of '
 
Code:
<input name="radiobuttonCustomData" type="radio" onclick="GetXmlHttpObject("Ajax.asp", stateChanged2, "CustomRecords", "Load=true")" value="true" />
to
Code:
<input name="radiobuttonCustomData" type="radio" onclick="GetXmlHttpObject('Ajax.asp', stateChanged2, 'CustomRecords', 'Load=true')" value="true" />

I don't know the answer but my good friend Google does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top