...

View Full Version : error on page in an AJAX example



joonstar
10-21-2006, 07:02 AM
code

<script type=text/javascript>
function showHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML=""
return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
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 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}

</script>

<form>
First Name:
<input type="text" id="txt1"
onkeyup="showHint(this.value)">
</form>

<p>Suggestions: <span id="txtHint"></span></p>

The code is from http://w3schools.com/ajax/ajax_example.asp

As I enter any character into the input field expecting the character is shown in the txtHint span area, it says "error on page" on the status bars.

What's wrong with the code? or What's wrong in my expecting?

If it needs any other file which I missed, where is it, please?

CFMaBiSmAd
10-21-2006, 02:22 PM
This example code uses a gethint.asp file and would only run on an IIS web server or other web server with .asp support.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum