Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : ajax

ajax»ù´¡¶ÁÊé±Ê¼Ç µÚÒ»ÕÂ

1¡¢XMLHttpRequest¶ÔÏóµÄ´´½¨
   ÓÉÓÚ  ²»ÊÇw3c±ê×¼£¬ËùÒÔʹÓÃJavascript´´½¨Ö®µÄ·½·¨Ò²²»Í¬£¡Internet explorer °ÑXMLHttpRequestʵÀý»¯Îª  ActiveX¿Ø¼þ£¬È»¶ø ÆäËûµÄä¯ÀÀÆ÷£¨FireFox£¬opera£©°ÑXMLHttpRequestʵÀý»¯Îª±¾µØµÄJavaScriptÒ»¸ö¶ÔÏó
ËùÒÔ Ö»ÒªÈ·¶¨ÊÇ·ñ  Ö§³Ö ActiveX¿Ø¼þ¶ÔÏ󣡣¡Èç¹ûÖ§³ÖÔò´´½¨ActiveX¿Ø¼þ£¡  Èç¹û²»Ö§³Ö£¬Ôò´´½¨  ±¾µØµÄJavascript¶ÔÏó
ÏÂÃæÒ»¸ö´úÂ룺
   var   xmlHttp£»
function  createXMLHttpRequest£¨£©
{
if(window.ActiveXObject)            //ÔòʹÓõÄÊÇInternet explorer ä¯ÀÀÆ÷
           xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest)
         xmlHttp=new XMLHttpRequest();
}
2  XMLHttpRequest ¶ÔÏóµÄ·½·¨
 
Ò»£ºopen(String method ,String URL,boolean )
method ÊDZíʾ  Ìá½»Êý¾ÝµÄ·½·¨£ºget  post  put ......

ajax»ù´¡¶ÁÊé±Ê¼Ç µÚÈýÕ£¨·¢ËÍÇëÇóÓë´¦ÀíÏìÓ¦£©

ͨ¹ýXMLHttpRequest.responseXML;
½«ÏìÓ¦½âÎöΪXML
»ñµÃ¶ÔÏóÓÐÏÂÃæµÄÊôÐԺͷ½·¨
±í3-1  ÓÃÓÚ´¦ÀíXMLÎĵµµÄDOMÔªËØÊôÐÔ
ÊôÐÔÃû
 ÃèÊö
 
childNodes
 ·µ»Øµ±Ç°ÔªËØËùÓÐ×ÓÔªËصÄÊý×é
 
firstChild
 ·µ»Øµ±Ç°ÔªËصĵÚÒ»¸öϼ¶×ÓÔªËØ
 
lastChild
 ·µ»Øµ±Ç°ÔªËصÄ×îºóÒ»¸ö×ÓÔªËØ
 
nextSibling
 ·µ»Ø½ô¸úÔÚµ±Ç°ÔªËغóÃæµÄÔªËØ
 
nodeValue
 Ö¸¶¨±íʾԪËØÖµµÄ¶Á/дÊôÐÔ
 
parentNode
 ·µ»ØÔªËصĸ¸½Úµã
 
previousSibling
 ·µ»Ø½ôÁÚµ±Ç°ÔªËØ֮ǰµÄÔªËØ
 
±í3-2¡¡ÓÃÓÚ±éÀúXMLÎĵµµÄDOMÔªËØ·½·¨
·½·¨Ãû
 ÃèÊö
 
getElementById(id) (document)
 »ñÈ¡ÓÐÖ¸¶¨Î©Ò»IDÊôÐÔÖµÎĵµÖеÄÔªËØ
 
getElementsByTagName(name)
 ·µ»Øµ±Ç°ÔªËØÖÐÓÐÖ¸¶¨±ê¼ÇÃûµÄ×ÓÔªËصÄÊý×é
 
hasChildNodes()
 ·µ»ØÒ»¸ö²¼¶ûÖµ£¬Ö¸Ê¾ÔªËØÊÇ·ñÓÐ×ÓÔªËØ
 
getAttribute(name)
 ·µ»ØÔªËصÄÊôÐÔÖµ£¬ÊôÐÔÓÉnameÖ¸¶¨
ÏÂÃæ¿´Ò»¸öʵÀý
ÃæµÄÀý×Ó¿ÉÒÔ¿´µ½£¬Ê¹ÓÃ×ñÑ­W3C DOMµÄJavaScriptÀ´¶ÁÈ¡XMLÎĵµÊǺεȼòµ¥¡£´úÂëÇåµ¥3-3ÏÔʾÁË·þÎñÆ÷Ïòä ......

AJAX+jspÎÞË¢ÐÂÑéÖ¤ÂëʵÀý

[list=1]
ÎÒÃÇÔÚ×öÑéÖ¤ÂëµÄʱºòÍùÍùÓÉÓÚÒª·´×÷±×£¬ÑéÖ¤ÓÐʱ¹ÊÒâ¼ÓÈë¶àµÄ¸ÉÈÅÒòËØ£¬ÕâʱÑéÖ¤ÂëÏÔʾ²»ºÜÇå³þ£¬Óû§¾­³£ÊäÈë´íÎó¡£ÕâÑù²»µ«ÒªÖØÐÂË¢ÐÂÒ³Ã棬µ¼ÖÂÓû§Ã»Óп´Çå³þÑéÖ¤Âë¶øÖØÌî¶ø²»ÊÇÐ޸ģ¬¶øÇÒÈç¹ûûÓÐÓÃsession±£´æÏÂÓû§ÊäÈëµÄÆäËüÊý¾ÝµÄ»°(ÈçÐÕÃû)£¬Óû§¸Õ¸ÕÊäÈëµÄÄÚÈÝÒ²²»´æÔÚÁË£¬ÕâÑù¸øÓû§Ôì³É²»ºÃµÄÌåÑé¡£
±¾ÀýÔÚÔ­ÓÐÑéÖ¤·½Ê½»ù´¡Ö®ÉÏÔö¼ÓÒ»¶Îjs£¬Í¨¹ýxmlhttpÀ´»ñÈ¡·µ»ØÖµ£¬ÒÔ´ËÀ´ÑéÖ¤ÊÇ·ñÓÐЧ£¬ÕâÑù¼´Ê¹Óû§ä¯ÀÀÆ÷²»Ö§³Öjs£¬Ò²²»»áÓ°ÏìËûµÄÕý³£Ê¹ÓÃÁË¡£
ΪÁË·ÀÖ¹×÷±×£¬µ±Óû§Á¬½Ó3´ÎÊäÈë´íÎóʱÔòÖØÔØÒ»ÏÂͼƬ£¬ÕâÑùÒ²ÀûÓÚÓû§ÒòΪͼƬÉϵÄÑéÖ¤Âë±æÈϲ»Çå¶øʹÖÕÎÞ·¨ÊäÈëÕýÈ·¡£
±¾Àý»¹ÌرðÊʺϼìÑéÓû§ÃûÊÇ·ñÓÐЧ£¬Ö»Òª´Óºǫ́×ö¸ösql²éѯ£¬·µ»ØÒ»¸öÖµ»òÊÇxml¼´¿É¡£(ÕâÖÖÀý×ÓÌ«¶à £¬¾ÍÔڴ˲»×¸ÊöÁË)¡£
±¾ÀýµÄÓŵãÔÚÓڷdz£·½±ãÓû§ÊäÈ룬¶øÇÒ¼õÉÙ¶Ô·þÎñÆ÷¶ËµÄÇëÇ󣬿ÉÒÔ˵¼È¸ÄÉÆÓû§ÌåÑé¶øÇÒÂÔ»á½ÚÊ¡´ø¿í³É±¾£¬µ«ÏàÓ¦µØÒªÔÚÒ³ÃæÉÏÔö¼ÓÒ»¶ÎJavaScript´úÂ룬ÔÚÄ¿Ç°ÍøËÙÔ½À´Ô½¿ìÈËÃÇÒªÇó±ã½ÝÊæÊʵĽñÌ죬ËƺõÎÒÃǸüӦעÒâÌṩ¸øÓû§Á¼ºÃµÄʹÓøÐÊÜ¡£ ´úÂëÈçÏ£¬
1,img.jsp,ÊäÈëÖ÷Ò³Ãæ
<%@ page contentType="text/html; charset=GBK" language="jav ......

AJAX+jspÎÞË¢ÐÂÑéÖ¤ÂëʵÀý

[list=1]
ÎÒÃÇÔÚ×öÑéÖ¤ÂëµÄʱºòÍùÍùÓÉÓÚÒª·´×÷±×£¬ÑéÖ¤ÓÐʱ¹ÊÒâ¼ÓÈë¶àµÄ¸ÉÈÅÒòËØ£¬ÕâʱÑéÖ¤ÂëÏÔʾ²»ºÜÇå³þ£¬Óû§¾­³£ÊäÈë´íÎó¡£ÕâÑù²»µ«ÒªÖØÐÂË¢ÐÂÒ³Ã棬µ¼ÖÂÓû§Ã»Óп´Çå³þÑéÖ¤Âë¶øÖØÌî¶ø²»ÊÇÐ޸ģ¬¶øÇÒÈç¹ûûÓÐÓÃsession±£´æÏÂÓû§ÊäÈëµÄÆäËüÊý¾ÝµÄ»°(ÈçÐÕÃû)£¬Óû§¸Õ¸ÕÊäÈëµÄÄÚÈÝÒ²²»´æÔÚÁË£¬ÕâÑù¸øÓû§Ôì³É²»ºÃµÄÌåÑé¡£
±¾ÀýÔÚÔ­ÓÐÑéÖ¤·½Ê½»ù´¡Ö®ÉÏÔö¼ÓÒ»¶Îjs£¬Í¨¹ýxmlhttpÀ´»ñÈ¡·µ»ØÖµ£¬ÒÔ´ËÀ´ÑéÖ¤ÊÇ·ñÓÐЧ£¬ÕâÑù¼´Ê¹Óû§ä¯ÀÀÆ÷²»Ö§³Öjs£¬Ò²²»»áÓ°ÏìËûµÄÕý³£Ê¹ÓÃÁË¡£
ΪÁË·ÀÖ¹×÷±×£¬µ±Óû§Á¬½Ó3´ÎÊäÈë´íÎóʱÔòÖØÔØÒ»ÏÂͼƬ£¬ÕâÑùÒ²ÀûÓÚÓû§ÒòΪͼƬÉϵÄÑéÖ¤Âë±æÈϲ»Çå¶øʹÖÕÎÞ·¨ÊäÈëÕýÈ·¡£
±¾Àý»¹ÌرðÊʺϼìÑéÓû§ÃûÊÇ·ñÓÐЧ£¬Ö»Òª´Óºǫ́×ö¸ösql²éѯ£¬·µ»ØÒ»¸öÖµ»òÊÇxml¼´¿É¡£(ÕâÖÖÀý×ÓÌ«¶à £¬¾ÍÔڴ˲»×¸ÊöÁË)¡£
±¾ÀýµÄÓŵãÔÚÓڷdz£·½±ãÓû§ÊäÈ룬¶øÇÒ¼õÉÙ¶Ô·þÎñÆ÷¶ËµÄÇëÇ󣬿ÉÒÔ˵¼È¸ÄÉÆÓû§ÌåÑé¶øÇÒÂÔ»á½ÚÊ¡´ø¿í³É±¾£¬µ«ÏàÓ¦µØÒªÔÚÒ³ÃæÉÏÔö¼ÓÒ»¶ÎJavaScript´úÂ룬ÔÚÄ¿Ç°ÍøËÙÔ½À´Ô½¿ìÈËÃÇÒªÇó±ã½ÝÊæÊʵĽñÌ죬ËƺõÎÒÃǸüӦעÒâÌṩ¸øÓû§Á¼ºÃµÄʹÓøÐÊÜ¡£ ´úÂëÈçÏ£¬
1,img.jsp,ÊäÈëÖ÷Ò³Ãæ
<%@ page contentType="text/html; charset=GBK" language="jav ......

AJAX ¼¼ÊõÈëÃÅ

index.jsp
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>AJAX ¼¼Êõ¼òµ¥Ó¦ÓÃ</title>
        <script type="text/javascript">
            var xmlhttp ;
            //1.´´½¨xmlHttpRequest ¶ÔÏó£¬ÕâÊÇ×îÖØÒªµÄÒ»²½
            function creatXMLHttpRequest(){
                if(window.XMLHttpRequest){
                    //IE7 IE8 FireFox Mozillar Safari ,Opera
             &nb ......

¶ÔAjaxµÄһЩ»ù±¾Àí½â

Ò»¡¢ajaxµÄÈëÃÅ
  1¡¢XMLHttpRequest¶ÔÏóµÄʹÓã¨Ê¹ÓÃXMLHttpRequest½âÎöxmlÎļþ£©
 onreadystatechange
Ö¸¶¨µ±readyStateÊôÐԸıäʱµÄʼþ´¦Àí¾ä±ú
 open()
´´½¨Ò»¸öеÄhttpÇëÇ󣬲¢Ö¸¶¨´ËÇëÇóµÄ·½·¨¡¢URLµÈÐÅÏ¢
 send()
·¢ËÍÇëÇóµ½http·þÎñÆ÷²¢½ÓÊÕ»ØÓ¦
 readyState
    ·µ»ØXMLHTTPÇëÇóµÄµ±Ç°×´Ì¬
 status
       ·µ»Øµ±Ç°ÇëÇóµÄhttp״̬Âë
 responseText
½«ÏìÓ¦ÐÅÏ¢×÷Ϊ×Ö·û´®·µ»Ø
 responseXML
½«ÏìÓ¦ÐÅÏ¢¸ñʽ»¯ÎªXml Document¶ÔÏó²¢·µ»Ø
out»ØÓ¦¿Í»§
£±¡¢“Ìí¼ÓÐÂÏî” Ð½¨Ò»¸öXMLÎļþÀ´´æ·ÅÒª±»µ÷ÓõÄÊý¾Ý¡£
XMLFile.xml
<?xml version="1.0" encoding="utf-8" ?>
<response>
    <res>
       ¶Ô²»Æð,µÇ¼ʧ°Ü!
    </res>
</response>
 
£²¡¢“Ìí¼ÓÐÂÏî” Ð½¨Ò»¸öJSPÒ³£¬Ìí¼Ó´úÂ룺
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ......

AJAXʵÏֵĶàÈËЭͬÉè¼Æ


Download board.zip - 39.6 KB - Old Version 
Download board_2008.zip - 55.03 KB  - Latest VS 2008 Version
Introduction  
This is an AJAX based WhiteBoard application. Typically unlike their desktop based counterparts, web applications need to be designed to use optimal server resources. This is one of the reasons for AJAX being popular. Here I demonstrate a powerful use of AJAX to make communication possible between two or more clients.
So, What can this do?
As I said, this is a WhiteBoard Application. Users are provided with certain drawing tools, color selections, etc. The basic idea is to share the user drawings among all the clients. All the users viewing the main page can participate in the drawing and share it with all other users. Clearing local canvas, server data, etc is also possible.
Background
A couple of years ago I was assigned the task of researching the capabilities of AJAX. Being a tech freak I was hell bent on convincing the client t ......
×ܼǼÊý:703; ×ÜÒ³Êý:118; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [109] [110] [111] [112] [113] [114] 115 [116] [117] [118]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ