P
Patrick.O.Ige
I have this Ajax script below that returns data ...
var xmlHttp
function showCustomer(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="getcustomer.aspx";
url=url+"?employeeID="+str;
//Adds a random number to prevent the server from using a cached file
url=url+"&sid="+Math.random();
//readyState property holds the status of the server response
//each time each time the readyState changes,
//the onreadystatechange function will be executed.
xmlHttp.onreadystatechange=stateChanged;
//To send off a request to the server we must use the open and send method
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
//window.alert(str);
}
//The stateChanged() function executes every time the state of the XMLHTTP
//object changes.
function stateChanged()
{
if (xmlHttp.readyState==4)
{
//The data sent back from the server can be retrieved with the responseText
property.
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari or any
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
In the HTML i have this:-
NAme1:-<input type="text" id="time" name="time">
<input type="button" id="btn"
onclick="showCustomer(document.getElementById('time'));"
value="button2"><div id="txtHint"></div>
But when i clcik the button i get the value:- [Object] instead of and
employeeid of 1,2 etc..
Am i missing something?
What should happen is u type in an integer lets say 1 or 2 and that goes to
the GetCustomer.aspx page and retrieve results
var xmlHttp
function showCustomer(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="getcustomer.aspx";
url=url+"?employeeID="+str;
//Adds a random number to prevent the server from using a cached file
url=url+"&sid="+Math.random();
//readyState property holds the status of the server response
//each time each time the readyState changes,
//the onreadystatechange function will be executed.
xmlHttp.onreadystatechange=stateChanged;
//To send off a request to the server we must use the open and send method
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
//window.alert(str);
}
//The stateChanged() function executes every time the state of the XMLHTTP
//object changes.
function stateChanged()
{
if (xmlHttp.readyState==4)
{
//The data sent back from the server can be retrieved with the responseText
property.
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari or any
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
In the HTML i have this:-
NAme1:-<input type="text" id="time" name="time">
<input type="button" id="btn"
onclick="showCustomer(document.getElementById('time'));"
value="button2"><div id="txtHint"></div>
But when i clcik the button i get the value:- [Object] instead of and
employeeid of 1,2 etc..
Am i missing something?
What should happen is u type in an integer lets say 1 or 2 and that goes to
the GetCustomer.aspx page and retrieve results