Hi all,
I am new to Ajax and developping a web application on using Ajax.
My script is successfully requesting the server and getting the responseText. But when i want to access the responseXML
it is giving null.
I am recieving XMLHttpRequest.responseXML as null each time I access it, where as XMLHttpRequest.responseText is returning every thing except the xml that I am writing at the server.
My code at server is as follows:
Code:
PrintWriter out = response.getWriter();
String valid;
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
if (user == null) { //checking the availability to update the page.
valid = "true";
request.setAttribute("validity", valid );
String validity =toXml(valid);
out.write(validity);
}else
valid = "false"; request.setAttribute("validity", valid );
String validity = toXml(valid); out.write(validity);
The method toXml is ;
Code:
private String toXml(String v) {
StringBuffer xml = new StringBuffer();
xml.append("<?xml version=\"1.0\"?>\n");
xml.append("<ajax generated=\""+System.currentTimeMillis()+"\" total=\""+0+"\">\n");
xml.append("<validity>");
xml.append(v);
xml.append("</validity>");
// TODO Auto-generated method stub
// Replace println methods to thsi part
return xml.toString();
}
I am expecting my code to return <validity>true or false </validity> on XMLHttpRequest.responseXML.getElemenyByTagName("validity");
Can any one please tell me where am I going wrong.
Thanx & Regards:
Yash(md_sagri@yahoo.com)