I am trying to call a webservice using javascript.But it shows an error like selectSingleNode() is not a method.I am trying it in mozilla firefox.Which is perfectly working in explorer when i change XMLHttpRequest to ActiveXObject.here i am adding my source code which i am tried in firefox.
<script language="javascript">
// Web Service functionality
// Global vars
var xmlDoc = null;
var _serviceCallback = null;
// Calls web service, web service url and parms, and callback function or null must be provided.
// Callback function receives a true or false based on success of call to host
function callWebService(url, callback)
{
_serviceCallback = callback;
if(xmlDoc == null)
{
// xmlDoc = new XMLHttpRequest();
xmlDoc = new XMLHttpRequest();
}
xmlDoc.onreadystatechange = stateChange; //callback for readystate
xmlDoc.async = true; //do background processing
//xmlDoc.load(url);
xmlDoc.open('GET', url);
xmlDoc.send();
//var doc= xmlDoc.responseXML;
}
// Updates readystate by callback
function stateChange()
{
if (xmlDoc.readyState == 4)
{
var err = xmlDoc.parseError;
var result = false;
var nd;
if(err.errorCode == 0)
{
nd = xmlDoc.selectSingleNode("//envelope/date_time");
if(nd.text != "")
result = true;
}
// perform callback if provided
if(_serviceCallback != null)
_serviceCallback(result, nd == null ? "" : nd.text);
}
}
// Callback supplied to XMLHttpRequest call
function callbackTest(result, data)
{
obj = document.getElementById("txtOuput");
if(result)
obj.value = "Success " + data;
else
obj.value = "Web Service Call Failed";
}
</script>
<input type="button" onclick="callWebService('http://www.hendricksongroup.com/services/WebService.asmx/GetTime?input=Test', callbackTest)" value="Click" />
<input type="text" id="txtOuput"/>
Please help me...Already which kill my 8 more hours...