Jump to content

Search the Community

Showing results for tags 'xmlparser'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. Hi All, i'm doing sample ajax exercise and getting the response from server but the response work fine in IE browser but not in firefox/chrome browser. below is the code snippet also find the snippet ========================= ajaxdemo.html =========================l <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <input type="text" id="inputDisplay" /> <button type="button" onclick="sendMessageToServer()">Send To Server</button><br/> <input type="text" id="textDisplay"/> <script type="text/javascript"> var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { isIE = true; xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } function sendMessageToServer() { xmlhttp.open("POST","/LabAjax04/AjaxDemoServlet?name="+document.getElementById("inputDisplay").value,true); xmlhttp.onreadystatechange=receiveMessageFromServer; xmlhttp.send(); document.getElementById("inputDisplay").value=''; } function receiveMessageFromServer() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { alert(xmlhttp.responseXML.getElementsByTagName("responseFromServer")[0].text);// displays undefined alert(xmlhttp.responseText);//display the response from server document.getElementById("textDisplay").value=xmlhttp.responseXML.getElementsByTagName("responseFromServer")[0].text; } } </script> </body> </html> ======================= java file ====================== package com.sample.ajax; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class AjaxDemoServlet */ public class AjaxDemoServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public AjaxDemoServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {} /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("server recived the folwwoing messgae from client:"+request.getParameter("name")); response.setContentType("text/xml"); response.getWriter().println("<responseFromServer>"+request.getParameter("name")+"</responseFromServer>"); System.out.println("server replied with the folwwoing messgae to client:"+request.getParameter("name")); } } ========= web.xml ========= <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>LabAjax04</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <description></description> <display-name>AjaxDemoServlet</display-name> <servlet-name>AjaxDemoServlet</servlet-name> <servlet-class>com.sample.ajax.AjaxDemoServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>AjaxDemoServlet</servlet-name> <url-pattern>/AjaxDemoServlet</url-pattern> </servlet-mapping> </web-app> Thanks in advance!!!
×
×
  • Create New...