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 人气:622
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

  • 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

  • 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

  • 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

  • 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

  • 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

  • Code Generation js_ 2009-06-25

    <pre name="code"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head>

  • What front is a verification code --- JavaScript --- small program 2010-06-25

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title> Untitled page </

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



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

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.124 (s). 13 q(s)