Reputation: 8767
I am calling a web service which is located on another host. It is working fine in IE but not in FF,Opera etc.. Here is my code :
if(xmlHttpReq.readyState == 0){
xmlHttpReq.open('POST', strURL, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200) {
var resultString = xmlHttpReq.responseXML;
document.getElementById('webserviceresponsetext').value = resultString.text;
}
}
xmlHttpReq.send(packet);
}
}
var packet = '<?xml version="1.0" encoding="utf-8" ?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> '+
'<soap:Body>'+
'<authenticate xmlns="http://interfaces.service.webservices.webs.eic.com">" '+
'<ParameterName>abc</ParameterName>'+
'<ParameterName>1234</ParameterName>'+
'</authenticate></soap:Body>'+
'</soap:Envelope>';
This method just calls authenticate method and returns true/false if user abc is valid user or not.1234 is password for abc user. Please help... Thanks in advance...
I am getting this error in FF:
XML Parsing Error: no element found Location: moz-nullprincipal:{cb5142f9-33a8-44ca-bc9d-60305ef7cea8} Line Number 1, Column 1:
Upvotes: 0
Views: 278
Reputation: 5619
If you want ajax to reliably work across browsers, I'd recommend using jQuery.
It'll abstract away the complexity of dealing with the XmlHttpReq directly, give you a much cleaner syntax and work across all major browsers.
Have a look at jQuery's ajax API for a start.
Your code could look similar to this:
$.ajax({
url: "test.html",
context: document.body,
success: function(){
$(this).addClass("done");
}
});
Upvotes: 1