I’m getting an Object Expected error on my production server, but not my preview server. The only difference (to my knowledge) is that my preview server uses an older version of IIS. But I don’t know why it would cause this error?
The error is on this line in my HTML:
<input type="text" id="txt1" onkeyup="showHint(this.value)" name="txtprjName" tabindex="1" size="100" maxlength="50" />
<span id="txtHint"></span>
showHint is refering to an external javascript file in the same directory as the HTML file.
<script language="javascript" type="text/javascript" src="clienthint.js"></script>
And the content of clienthint.js is this:
var xmlHttp
function showHint(str){
if (str.length==0){
document.getElementById("txtHint").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
alert ("Your browser does not support AJAX!");
return;
}
var url="gethint.asp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() {
if (xmlHttp.readyState==4){
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject(){
var xmlHttp=null
try{
// Internet Explorer
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try{
// Internet Explorer
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
}
return xmlHttp;
}
Not sure why this isn’t working? Any ideas? Thanks.
I moved the javascript to the main web page instead of having it included externally, and the code works now.