Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ajax½øÐÐÓû§µÄÓÐЧÐÔ¼ì²âʾÀý

ajax½øÐÐÓû§µÄÓÐЧÐÔ¼ì²âʾÀý
1¡¢  ÊäÈëÓò£º
»áÔ±µÄÓÐЧÐÔ¼ì²é£º
     <input type="text" name="username">&nbsp;&nbsp;<input type="button" value="¼ì²é" onclick="return check();">
2¡¢  JavaScript½Å±¾£º
var xmlHttp;
    //´´½¨XMLHttpRequest¶ÔÏó
    function createXMLHttpRequest() {
       if(window.ActiveXObject) {
           xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
       } else if (window.XMLHttpRequest) {
           xmlHttp = new XMLHttpReuqest();
       }
    //×¢²áÃûÓÐЧÐÔ¼ì²é
    function check() {
       var username = document.getElementById('username').value;
       if(username=="") {
           alert("Óû§Ãû²»ÄÜΪ¿Õ£¡");
           return;
       }
       createXMLHttpRequest();
       xmlHttp.onreadystatechange = processCheck;
       xmlHttp.open("GET", "CheckUser?username=" + username);
       xmlHttp.send(null);
    }
      
    //°ó¶¨µÄÓÐЧÐÔ¼ì²éº¯Êý
    function processCheck() {
       var result;
       if(xmlHttp.readyState == 4) { //Èç¹ûÏìÓ¦Íê³É
           if(xmlHttp.status == 200) { //Èç¹û·µ»Ø³É¹¦
              result = xmlHttp.responseText;
      &


Ïà¹ØÎĵµ£º

IDE ȱÉÙ»ù´¡ÄÜÁ¦¼¯µ÷Óÿ⣬ÕâÊÇÒ»¸ö¼òµ¥µÄAjaxµ÷Óá£

var jsonObj;
var xmlhttp = null;
function callAsync(url, callbackSuccess)
{
 xmlhttp = new Ajax();
 xmlhttp.open("GET", url, true);
 xmlhttp.onreadystatechange=function()
 {
  // readyState = 4 ; "complete"
  if (xmlhttp.readyState==4)
  { ......

Java Web»ù´¡£ºµÚ¶þʮһ½² Ajax½»»¥µÄ»ù±¾¹ý³Ì

±¾ÎÄÄÚÈÝÕª×Ô£º¡¶Java Web¿ª·¢½Ì³Ì——ÈëÃÅÓëÌá¸ßƪ£¨JSP+Servlet£©¡·
½»»¥µÄ»ù±¾¹ý³Ì°üÀ¨£º
l         ´´½¨XMLHttpRequest¶ÔÏó£»
l         ·¢ËÍÇëÇó£»
l         ´¦ÀíÏìÓ¦¡£
´ ......

ʲôÊÇAjax¼¼Êõ£¿

 
 
1.ʲôÊÇAjax?
AjaxµÄÈ«³ÆÊÇ£ºAsynchronousJavaScript+XML
2.AjaxµÄ¶¨Ò壺
Ajax²»ÊÇÒ»¸ö¼¼Êõ£¬Ëüʵ¼ÊÉÏÊǼ¸ÖÖ¼¼Êõ£¬Ã¿ÖÖ¼¼Êõ¶¼ÓÐÆä¶ÀÌØÕâ´¦£¬ºÏÔÚÒ»Æð¾Í³ÉÁËÒ»¸ö¹¦ÄÜÇ¿´óµÄм¼Êõ¡£
3.Ajax°üÀ¨£º
XHTMLºÍCSS
ʹÓÃÎĵµ¶ÔÏóÄ£ÐÍ(DocumentObjectModel)×÷¶¯Ì¬ÏÔʾºÍ½»»¥
ʹÓÃXMLºÍXSLT×öÊý¾Ý½»»¥ ......

js Ajax Àà Éú»îÒª¿ìÀÖ

/*
κÑÔAJAX Àà
ʹÓ÷½·¨:
<mce:script type="text/javascript"><!--
var classAjax = new Ajax(sUrl,sRecvTyp,sQueryString,oResultFunc);
classAjax.post();//post·½Ê½·¢ËÍÊý¾Ý
classAjax.get();//get·½Ê½·¢ËÍÊý¾Ý
//sUrl·¢Ë͵ØÖ·
//sRecvTyp ½ÓÊÜÊý¾ÝÀàÐÍ:0Ϊxml 1Ϊtext
//oResultFunc ·µ»Ø½á¹û´¦Àíº ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ