AJAX response to the basic implementation of a simple example

Send requests for the page code

<html>
 <head>
  <title>ajax</title>
  <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
	  xmlHttp.send(null);
	}

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

</script>

 </head>
<body>
 	<input type="text">
	<input type="text">
</body>
</html>

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

分类:AJAX 时间:2009-03-08 人气:556
分享到:
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 ...

  • 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, no

  • 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 pa

  • 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="button" value=" Check "> <div

  • 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 st ...

  • C # Implementation WEB server 2010-03-07

    This is a simple to use C # to write the WEB server, only way to achieve a get html files on the request of interested friends can continue to develop on this basis more features! Abstract: WWW's work is based on client / server computing model, the W

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

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

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

processed in 0.298 (s). 14 q(s)