AJAX response to the basic implementation of a simple example

Send requests for the page code

  <script language="javascript">
  /* Create a new XMLHttpRequest object to talk to the Web server */
	var xmlHttp = false;
	try {
	  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (e2) {
		xmlHttp = false;

	//Send AJAX requests
	function callServer()
	  // Get the city and state from the web form
	  var city = document.getElementById("city").value;
	  // Only go on if there are values for both fields
	  if ((city == null) || (city == "")) return;
	  // Build the URL to connect to
	  var url = "returnvalue.txt";//Here is an XML file, a page, etc.
	  // Open a connection to the server
	  xmlHttp.open("GET", url, true);
	  // Setup a function for the server to run when it's done
	  xmlHttp.onreadystatechange = updatePage;
	  // Send the request

	function updatePage()
	  if (xmlHttp.readyState == 4) {
		var response = xmlHttp.responseText;
		document.getElementById("returnValue").value = response;


 	<input type="text">
	<input type="text">

The results of their implementation are the content of the text file back to the
<input type="text"> show

分类:AJAX 时间:2009-03-08 人气:558
blog comments powered by Disqus


  • Implementation of small Web server 2010-05-31

    I believe many of my friends have read "Core Servlets and JSP Volume I", which the author wrote a small Web server (EchoServer) achieved very beneficial to our analysis of HTTP protocol. Its main implementation principle is: EchoServer open a So

  • Live text mode web server implementation of active distribution 2010-09-28

    Development of the site, occasionally met with some, like chat rooms, text the studio this demand. One feature of this demand is the need to constantly refresh the information, subject to the HTTP protocol, if the page to refresh your page frequently

  • In Firefox, to access Web resources through cross-domain AJAX 2010-07-06

    Reprinted http://www.blogjava.net/nokiaguy/archive/2008/05/15/200678.html 1, firefox can not resolve the problem cross-domain access In essence, AJAX is the name to use XMLHttpRequest to the server component to send HTTP request to receive the approp

  • Achieved with a simple java web server 2010-07-26

    Always say that they are doing web development, it gives no knowledge http protocol, slightly ashamed few days ago, more leisure, to study a little http protocol and web server, using java to do a simple web server, of course, too simple, and can onl

  • JSP implementation code to send e-mail with an attachment 2010-03-29

    SendAttanchment.jsp file -------------------------------- test file <% @ Page language = "java" import = "java.util .*" pageEncoding = "ISO-8859-1"%> <html> <head> <base href ="<%= basePath%> &

  • VI. Tomcat Web server security solutions 2010-10-06

    1 Overview In any kind of WEB application development, regardless of medium and small scale, each developer will encounter some problems need to protect application data, related to the user's LOGIN ID and PASSWORD. So how to implement authentication

  • iis7.0 official download IIS 7.0 (Microsoft's Web server component of IIS 7.0) the official (windows 2003, XP, 2000) 2010-11-18

    iis7.0 download the official installation package iis7 web server when developing a new generation of Microsoft's server software, security, compared with iis5 \ iis6 are improved, a lot of users looking for iis7 Download the full installation packag

  • AJAX XMLHTTPRequest object for asynchronous data exchange 2010-07-03

    <html> <head><title>Simple jsp page</title> <script type="text/javascript" src="js/verify.js"></script> </head> <body> <input type="text"><br> <input type="b

  • AJAX - XMLHttpRequest Object Browser Support 2010-12-03

    AJAX is the XMLHttpRequest object points. Create a different browser XMLHttpRequest object is different. IE browser uses the ActiveXObject, while other browsers use the name The built-in JavaScript XMLHttpRequest object. For a different browser to cr

  • Web server with the Java implementation 2009-07-18

    WWW's work is based on client / server computing model, from the Web browser (client) and Web server (server) constituted between the use of Hypertext Transfer Protocol (HTTP) for communication, HTTP protocol, including the role of Principle 4 steps:

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.335 (s). 10 q(s)