µÚÒ»¸öAjax ʵÀý
<!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=gb2312" />
<title>¼òµ¥µÄÓ¦ÓÃXMLHttpRequestÀý×Ó</title>
<mce:script type="text/javascript"><!--
var req = null; // XMLHttpRequest¶ÔÏó
var console = null; // Êä³ö½á¹ûµÄDIV¶ÔÏó
/* ÒÔÏÂËĸö¶ÔÏóÊÇÒì²½´«Êä¹ý³ÌÖеÄËÄÖÖ״̬ */
var READY_STATE_UNINITIALIZED = 0;
var READY_STATE_LOADING = 1;
var READY_STATE_LOADED = 2;
var READY_STATE_INTERACTIVE = 3;
var READY_STATE_COMPLETE = 4;
/*
* ·¢ËÍÒ»¸öÒì²½µÄÇëÇó
* ²ÎÊý: url Ä¿±êµØÖ·, params·¢Ë͵IJÎÊý, HttpMethod ·½·¨¿ÉÒÔGET»òPOST
* µÚ¶þ¸öµÚÈý¸ö²ÎÊýÒ»°ã¿ÉÒÔÊ¡ÂÔ,µ±µÚÈý¸ö²ÎÊýÊ¡ÂÔʱHttpMethodĬÈÏΪGET
* µ±ÇëÇó·¢ËÍÍê³Éʱµ÷ÓÃcallbackº¯Êý½øÐвÙ×÷
*/
function sendRequest( url, params, HttpMethod ){
if( !HttpMethod ){
HttpMethod = "GET";
}
req = initXMLHTTPRequest();
if( req ){
req.onreadystatechange = callback;
req.open( HttpMethod, url, true );
req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
req.send( params );
}
}
/*
* ½¨Á¢ÓÃÓÚÒì²½´«ÊäµÄXMLHttpRequest¶ÔÏó
*/
function initXMLHTTPRequest(){
var xRequest = null;
if( window.XMLHttpRequest ){
xRequest = new XMLHttpRequest(); // Mozilla, Sofira, Firefox
}
else if( window.ActiveXObject ){
xRequest = new ActiveXObject("Microsoft.XMLHTTP"); // IE
}
return xRequest;
}
/*
* »Øµ÷º¯Êý
* ½«´¦Àí¹ý³Ì¼°Íê³Éʱ·µ»ØµÄ½á¹ûÎı¾½»¸øtoConsole½øÐд¦Àí
*/
function callback(){
var ready = req.readyState;
var data = null;
if( ready == READY_STATE_COMPLETE ){
data = req.responseText;
}
else{
data = "loading...[" + ready + "]";
}
toConsole( data );
}
/*
* ÏÔʾ½á¹û
* ÔÚDOMÖÐÕÒµ½IDΪconsoleµÄÔªËØ,½«ÏÔʾ½á¹û×·¼Óµ½consoleÖÐ
*/
fun
Ïà¹ØÎĵµ£º
ºÜ¶àÅóÓÑÎÊÎÒÈçºÎʵÏÖÎÞË¢ÐÂÉÏ´«Í¼Æ¬,ÕâÀïСºÚ¸ø´ó¼ÒÕÒÁËһƪ¹ØÓÚÎÞË¢ÐÂʵÏÖͼƬÉÏ´«µÄÎÄÕÂ,Ï£Íû¶Ô´ó¼ÒÓаïÖú.
±¾ÎÄ¿Í·þ¶ËʹÓõÄÊÇajax.netÒì²½ÉÏ´«Îļþ
1.ÔÚ
protected void Page_Load(object sender, EventArgs e)
{
Ajax.Utilit ......
AJAX¼¼Êõ½éÉÜ
AJAX µÄÈ«³ÆÖ¸Òì²½µÄ JavaScript ¼° XML£¨Asynchronous JavaScript And XML£©
ÔÚѧϰAJAX֮ǰ£¬ÄãÐèÒªÁ˽âµÄ֪ʶÓУº
HTML / XHTML
JavaScript
µ±È»»¹ÓÐһЩÆäËûµÄ¼¼Êõ£ºCSS¡¢DOM¡¢XML¡¢XMLHttpRequest
AJAX ²»ÊÇÒ»ÖÖеıà³ÌÓïÑÔ£¬¶øÊÇÒ»ÖÖÓÃÓÚ´´½¨¸üºÃ¸ü¿ìÒÔ¼°½»»¥ÐÔ¸üÇ¿µÄ Web Ó¦ÓóÌÐòµÄ¼¼Êõ¡£
ͨ¹ ......
Ò».¹¤¾ßÏÂÔØ
1.ASPAJAXExtSetup.msi
http://download.microsoft.com/download/5/4/6/5462bcbd-e738-45fa-84ca-fa02b0c4e1c2/ASPAJAXExtSetup.msi
2.ASPAJAXSourceCode.msi
http://download.microsoft.com/download/6/d/6/6d6c7c47-b9ff-4934-bb03-8a45b8418d35/ASPAJAXSourceCode.msi
3.AjaxControlToolkit
http://ww ......
µ½×îºóÎҲŷ¢ÏÖ΢Èí¸øµÄajax json ʵÀý¶¼ÊÇÓÐÎÊÌâµÄ£¬ºÜ¶à¶¼ÊDz»ÑÏÃܵģ¬ÌرðÊǶÔÓÚ´óСд·½Ã棬ËûÃǶ¼Ã»ÓÐ×Ðϸ׷¾¿´óСдÎÊÌ⣬µ¼ÖÂÁËÔÚfirefoxʹÓÃÓÐÎÊÌâ¡£ÏÂÃæÊÇʵÀýÄÚÓãºÁ½¸öhtmlÖ®¼äµÄ£º
<head> <title>²âÊÔajax</title> <meta http-equiv=”Content-Type” content=”text/ht ......
ŪÁËÒ»ÕûÌìÁË£¬¸Õ¿ªÊ¼Ñ§Ï°Jquery£¬ºÜ¶à¶«Î÷»¹²»Ê죬¿´¿´ÊÓƵ£¬²é²é×ÊÁÏ£¬ÖÕÓڳɹ¦µÄ¼¯³ÉStruts2+Jquery+Json
Ö±½ÓÉÏͼ:Óû§ÃûÊäÈëxxx,½¹µã¶ªÊ§£¬Ìáʾ”Óû§ÒÑ´æÔÚ“£¬·ñÔòÌáʾ“¿ÉÒÔ×¢²á“£¬ÃÜÂëͬÑùÈç´Ë,
Ê×ÏÈÐèÒªµ¼°ü£ºÈçϳýÁËstruts2±ØÐëµÄ°üÍ⣬»¹ÓÐjson°üÒÔ¼°Éæ¼°µÄcommonsµÄ¼¸¸ö°ü.
´ËÍâҪϠ......