dcsimg
Problem with responseXML
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sweta_Gupta
Posted On:   Monday, September 10, 2007 10:16 PM

Can any body help me please? The code is as follows: The request is made as follows in javascript function validateLogin() { req = newXMLHttpRequest(); var url = "http://localhost:8090/RealEstateProject/UserLogin"; req.open("GET", url, true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.onreadystatechange = updateMsg; req.send(null); } The updateMsg is as follows: function updateMsg() { if (req.readyState==4 ) { responseFromServlet = req.responseXML; var cart = responseFromServlet.getElementsByTag   More>>

Can any body help me please?



The code is as follows:


The request is made as follows in javascript



function validateLogin() {
req = newXMLHttpRequest();
var url = "http://localhost:8090/RealEstateProject/UserLogin";
req.open("GET", url, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.onreadystatechange = updateMsg;
req.send(null);
}


The updateMsg is as follows:



function updateMsg() {
if (req.readyState==4 ) {
responseFromServlet = req.responseXML;
var cart = responseFromServlet.getElementsByTagName("cart")[0];
//var item = cart.getElementsByTagName("item");//.firstChild.nodeValue;
//var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
//alert (name);
alert("response Text: "+responseFromServlet);


The variable item is not coming and the error is object does not support this.


The responseFromServlet is coming null.



at the servlet end



response.setContentType("text/xml");
String xmlL = toXml();
System.err.println(xmlL);
response.getWriter().write(xmlL);


The toXML method is:



public String toXml() {
StringBuffer xml = new StringBuffer();
xml.append(" <?xml version="1.0"?>
");
xml.append("
");

xml.append("
");
xml.append(" ");
xml.append("Sweta GUPTA");
xml.append("
");
xml.append(" ");
xml.append("Papa gupta");
xml.append("
");
xml.append("
");

xml.append("
");
return xml.toString();
}

   <<Less

Re: Problem with responseXML

Posted By:   Axel_Richter  
Posted On:   Wednesday, September 12, 2007 06:12 AM

Hi,



please replace

...
responseFromServlet = req.responseXML;
...

with

...
responseFromServlet = req.responseText;
...

comment out all up to the alert and look at the responsed text. If you then think, everything is right with the response, post the responsed text here.



You also may get the XML (http://localhost:8090/RealEstateProject/UserLogin) directly with the Firefox and look at Firefox [Tools - Page Info] which content type really comes up.



greetings



Axel
About | Sitemap | Contact