<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script language="javascript">
function saveUserInfo()
{
//»ñÈ¡½ÓÊÜ·µ»ØÐÅÏ¢²ã
var msg = document.getElementById("msg");
//»ñÈ¡±íµ¥¶ÔÏóºÍÓû§ÐÅÏ¢Öµ
var f = document.user_info;
var userName = f.user_name.value;
var userAge = f.user_age.value;
var userSex = f.user_sex.value;
//½ÓÊÕ±íµ¥µÄURLµØÖ·
var url = "/ajax_output.php";
//ÐèÒªPOSTµÄÖµ£¬°Ñÿ¸ö±äÁ¿¶¼Í¨¹ý&À´Áª½Ó
var postStr = "user_name="+ userName +"&user_age="+ userAge +"&user_sex="+ userSex;
//ʵÀý»¯Ajax
//var ajax = InitAjax();
var ajax = false;
//¿ªÊ¼³õʼ»¯XMLHttpRequest¶ÔÏó
if(window.XMLHttpRequest) { //Mozilla ä¯ÀÀÆ÷
& ......
AjaxµÄÔÀíºÜ¼òµ¥£¬¾ÍÊÇÔÚ¿Í»§¶Ë´´½¨Ò»¸öXMLHttpRequest¶ÔÏó£¨ÓÃÀ´Óë·þÎñÆ÷½øÐÐÒ첽ͨÐÅ£¬Õâ¾ÍÊÇAjaxµÄºËÐÄ£¬ÆäʵÎÒÃÇÔç¾ÍÔÚÓÃÒ첽ͨÐÅÁË£¬Ö»ÊÇû°ÑÕâÏî¼¼ÊõÓÃÔÚÍøÒ³Éè¼ÆÖжøÒÑ£©£¬Îª¸Ã¶ÔÏóµÄonreadystatechange ÊôÐÔÌí¼ÓÒ»¸öʼþ£¬µ±¶ÔÏóµÄreadyState¸Ä±äµÄʱºò¾Í»áÒý·¢Ö¸¶¨µÄʼþ¡£µ½´Ë¾Í¿ÉÒԾͷ¢ËÍÇëÇó¶ÁÈ¡·þÎñÆ÷¶ËµÄXMLÊý¾ÝÁË£¬×îºóÒª×öµÄ¾ÍÊÇ´¦ÀíÊý¾ÝÁË¡£ ¹ØÓÚXMLHttpRequest¶ÔÏó£¬Çë²Î¿¼ About XMLHttpRequest ObjectÒ»ÎÄ¡£
¿´Àý×Ó£º
¸´ÖÆ´úÂë
//AjaxDemo.html
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Asynchronous java script And XML</title>
</head>
<body>
<script type="text/java script">
var xmlHttp=null;
function readyState ......
ÔÎĵØÖ·¡¿Announcing the Microsoft AJAX CDN
¡¾ÔÎÄ·¢±íÈÕÆÚ¡¿ Tuesday, September 15, 2009 11:46 PM
½ñÌìÔçЩʱºò£¬ASP.NET¿ª·¢ÍŶÓÍƳöÁËÒ»¸öеÄ΢ÈíAjax CDN£¨Content Delivery Network£¬ÄÚÈÝ·Ö·¢ÍøÂ磩·þÎñ£¬¸Ã·þÎñÌṩÁ˶ÔAJAX¿â£¨°üÀ¨jQuery ºÍ ASP.NET AJAX£©µÄ»º´æÖ§³Ö¡£¸Ã·þÎñÊÇÃâ·ÑµÄ£¬²»ÐèÈκÎ×¢²á£¬¿ÉÓÃÓÚÉÌÒµÐÔ»ò·ÇÉÌÒµÐÔÓÃ;¡£
CDN¶¼Ìṩʲô£¿
ÄÚÈÝ·Ö·¢ÍøÂ磨CDNs£©ÊÇÓÉÕ½ÂÔÐÔµØÖ÷ÅÓÚÊÀ½ç¸÷µØ¹Ø¼üInternetÍøÂçµãµÄ“±ßÔµ»º´æ£¨edge cache£©”·þÎñÆ÷×é³ÉµÄ¡£ÕâЩ“±ßÔµ»º´æ£¨edge cache£©”·þÎñÆ÷¿ÉÓÃÓÚ»º´æºÍ·Ö·¢¸÷ÖÖÀàÐ͵ÄÄÚÈÝ£¬°üÀ¨Í¼Æ¬£¬ÊÓƵ£¬CSSºÍJavaScriptÎļþ¡£
ʹÓÃCDN¿ÉÒÔÏÔÖøÌá¸ßÒ»¸öÍøÕ¾µÄÖÕ¶ËÓû§ÐÔÄÜ£¬ÒòΪËüÔÊÐíä¯ÀÀÆ÷¸ü¿ìµØ»ñÈ¡ºÍÏÂÔØÄÚÈÝ¡£ÀýÈ磬¶ÔÒ»¸öͼƬÇëÇó£¬ä¯ÀÀÆ÷²»ÔÙÐèÒª¿çÔ½Internetµ½ÄãµÄweb·þÎñÆ÷ÏÂÔØ£¬Ò»¸öCDN¿ÉÒÔ´ÓÁÚ½üµÄ“±ßÔµ»º´æ£¨edge cache£©”·þÎñÆ÷Ö±½ÓÌṩ·þÎñÂú×ã¸ÃÇëÇ󣬶ø¸Ã±ßÔµ»º´æ·þÎñÆ÷¿ÉÄÜÓëÄãµÄ¿Í»§Ö»ÓÐÒ»¸öÍøÂçµ¥Ìø£¨single network hop£©Ö®Ô¶£¨Ê¹Ö®·µ»Ø·Ç³£Ö®¿ì£¬Ò²Ê¹µÃÄãµÄÍøÒ³×°Ôظü¿ì£©¡£
΢ÈíAJAX CDN¶¼Ìṩʲô£¿
΢ÈíAJAX CDN¼«´óµØ·½±ãÁ˽«jQueryºÍ ......
Ò» ÒýÌâ
ÈçºÎÈÃweb³ÌÐòÓÃÆðÀ´Ïñ×ÀÃæÓ¦ÓóÌÐòÒ»Ñù¼òµ¥£»
ÅÖ¿Í»§¶Ë£¿ÊÝ¿Í»§¶Ë£¿ÈçºÎÑ¡Ôñ£¿-----¿´ÐèÇ󣬿´Óû§µÄʹÓã¬Áé»îµ÷½Ú¡£
²»ÒªÉÁ˸£¬¿Õ°×Ò³³öÏÖ£¿
¶þ ³õʶAjax
1. AjaxÊÇÒ»¸ö¿Í»§¶Ë¼¼Êõ£¬²»ÂÛÄãÏÖÔÚʹÓúÎÖÖ·þÎñÆ÷¶Ë¼¼Êõ£¬¶¼ÄÜʹÓÃAjax£¬¶ø²»¹ÜʹÓõÄÊÇJava¡¢.NET¡¢Ruby¡¢PHP»¹ÊÇCGI¡£
2. AjaxÊÇÒ»ÖÖ»ùÓÚä¯ÀÀÆ÷µÄ·½·¨£»
3. Ajax²»ÊÇȫеÄÍøÒ³¼¼Êõ£¬ËüÊÇÒÔÒ»ÖÖз½·¨À´ÕûºÏÏÖ´æµÄ¶àÖÖÍøÒ³¼¼Êõ£»
4. Ч¹ûÈ磺Google Suggest£»
5. AjaxÏà¹Ø¼¼ÊõÈçÏ£º
¡ô HTML/XHTMLºÍCSS£ºÔÚä¯ÀÀÆ÷ÏÔʾÓû§½Ó¿ÚºÍ³ÊÏÖÏà¹ØÊý¾Ý£»
¡ô JavaScript£»ËùÓеÄä¯ÀÀÆ÷¶¼Ö§³ÖJavaScript½Å±¾ÓïÑÔ¡£AJAXʹÓÃJavaScript½Å±¾ÓïÑÔÀ´²Ù×÷XmlHttpRequest¶ÔÏó¡¢²Ù×÷DOMºÍCSSµÈ¡£
¡ô XML£º·þÎñÆ÷Òì²½´«µÝµÄÊý¾Ý£»
¡ô XMLDOM:µ±ä¯ÀÀÆ÷Òì²½»ñÈ¡XMLÊý¾Ýºó£¬¿ÉÒÔ½øÒ»²½µÄʹÓÃJavaScript³ÌÐò´úÂëºÍXML DOMÀ´È¡³öÏà¹ØµÄÐÅÏ¢£»
¡ô XMLHTTPRequest¶ÔÏó£ºJavaScript´úÂëʶͨ¹ýXMLHTTPRequest¶ÔÏóÀ´½¨Á¢Òì²½µÄHTTPÇëÇó£»
×¢Ò⣺¶ÔÓÚһЩÏà¹Ø¼¼Êõ£¬Äã²»±ØÊÇÕâ·½ÃæµÄ× ......
1¡¢PHP·¢ËÍÖÐÎÄ¡¢Ajax½ÓÊÕ
Ö»ÐèÔÚphp¶¥²¿¼ÓÈëÒ»¾ä£º
header('Content-type: text/html;charset=GB2312');
xmlHttp»áÕýÈ·½âÎöÆäÖеÄÖÐÎÄ¡£
2¡¢Ajax·¢ËÍÖÐÎÄ¡¢PHP½ÓÊÕ
Õâ¸ö±È½Ï¸´ÔÓ£º
AjaxÖÐÏÈÓÃencodeURIComponent¶ÔÒªÌá½»µÄÖÐÎĽøÐбàÂë
PHPÖУº
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//IGNORE’ , $RequestAjaxString);
3¡¢PHPдÈëMySQLÊý¾Ý¿â
½¨Á¢connʱ£¬queryÒ»ÏÂset names “gb2312″ ......
1¡¢PHP·¢ËÍÖÐÎÄ¡¢Ajax½ÓÊÕ
Ö»ÐèÔÚphp¶¥²¿¼ÓÈëÒ»¾ä£º
header('Content-type: text/html;charset=GB2312');
xmlHttp»áÕýÈ·½âÎöÆäÖеÄÖÐÎÄ¡£
2¡¢Ajax·¢ËÍÖÐÎÄ¡¢PHP½ÓÊÕ
Õâ¸ö±È½Ï¸´ÔÓ£º
AjaxÖÐÏÈÓÃencodeURIComponent¶ÔÒªÌá½»µÄÖÐÎĽøÐбàÂë
PHPÖУº
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//IGNORE’ , $RequestAjaxString);
3¡¢PHPдÈëMySQLÊý¾Ý¿â
½¨Á¢connʱ£¬queryÒ»ÏÂset names “gb2312″ ......
1¡¢PHP·¢ËÍÖÐÎÄ¡¢Ajax½ÓÊÕ
Ö»ÐèÔÚphp¶¥²¿¼ÓÈëÒ»¾ä£º
header('Content-type: text/html;charset=GB2312');
xmlHttp»áÕýÈ·½âÎöÆäÖеÄÖÐÎÄ¡£
2¡¢Ajax·¢ËÍÖÐÎÄ¡¢PHP½ÓÊÕ
Õâ¸ö±È½Ï¸´ÔÓ£º
AjaxÖÐÏÈÓÃencodeURIComponent¶ÔÒªÌá½»µÄÖÐÎĽøÐбàÂë
PHPÖУº
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//IGNORE’ , $RequestAjaxString);
3¡¢PHPдÈëMySQLÊý¾Ý¿â
½¨Á¢connʱ£¬queryÒ»ÏÂset names “gb2312″ ......
Ê×Ïȶ¼ÊÇʹÓÃVS.Net2005´´½¨Ò»¸ö ASP.Net AJAX-Enabled Web Application
1¡¢Ê¹ÓÃAJAXÖ±½Óµ÷Óúǫ́·½·¨£º
ºǫ́´úÂ룺
namespace AJAX1
{
public partial class _Default : System.Web.UI.Page
{
// ÐèÒª±êʶΪWebMethod
[System.Web.Services.WebMethod]
// ×¢Ò⣬ҪÈÃǰ̨µ÷Óõķ½·¨£¬Ò»¶¨ÒªÊÇpublicºÍstaticµÄ
public static string Hello(string name)
{
return "Hello:" + name;
}
}
}
ǰ̨´úÂ룺
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAX1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ......