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

»ùÓÚJQuery¿ò¼ÜµÄAJAX,AJAXµÄÈýÖÖʵÏÖ·½Ê½

»ùÓÚJQuery¿ò¼ÜµÄAJAX
Ç°¼¸Ìì·¢Á˸öÌù£¬·ÖÏíÁËprototype¿ò¼Ü¹ØÓÚAJAX·½ÃæµÄѧϰ¹ý³Ì¡£È»ºóÓÐÈË˵jquery¿ò¼Ü¸ü·½±ã¡£
ÕýºÃÏîÄ¿ÖÐ×¼±¸Ê¹ÓÃthickbox£¬ÓÚÊǸɴàÅ×Æúprototype.js£¬¿´Æðjquery.jsÁË¡£JQueryȷʵ²»´í£¬Ìå»ý±È PrototypeСÁËÐí¶à£¬¶øÇÒʹÓÃÆðÀ´¸ü·½±ã¸üÁé»î¡£ÓÐÈË˵PrototypeÏñJAVA£¬Õýͳ£»¶øJQueryÏñRuby£¬Áé»î£¬¸üÇ÷ÓÚOOP¡£
СÊÔÁËÏÂAJAX£¬¸Ð¾õ±Èprototype¼ò½à¶àÁË£¬ÔÚJQueryÖУ¬AJAXÓÐÈýÖÖʵÏÖ·½Ê½£º$.ajax(),$.post,$.get()¡£
XHTML(Ö÷Òª):
<div id="result" style="background:orange;border:1px solid red;width:300px;height:400px;"></div>
<form id="formtest" action="" method="post">
<p><span>ÊäÈëÐÕÃû:</span><input type="text" name="username" id="input1" /></p>
<p><span>ÊäÈëÄêÁä:</span><input type="text" name="age" id="input2" /></p>
<p><span>ÊäÈëÐÔ±ð:</span><input type="text" name="sex" id="input3" /></p>
<p><span>ÊäÈ빤×÷:</span><input type="text" name="job" id="input4" /></p>
</form>
<button id="send_ajax">Ìá½»</button>
<button id="test_post">POSTÌá½»</button>
<button id="test_get">GETÌá½»</button>
JS:
1¡¢ÒýÈëjquery¿ò¼Ü£º
<scrīpt   type="text/javascrīpt" src="../js/jquery.js"></scrīpt>
2¡¢¹¹½¨AJAX£¬JQUERYµÄºÃ´¦ÊDz»ÐèÒªÔÚXHTMLÖÐʹÓÃJS´úÂëÀ´´¥·¢Ê¼þÁË£¬¿ÉÒÔÖ±½Ó·â×°ÔÚJSÎļþÖУº
<scrīpt type="text/javascrīpt">
//$.ajax()·½Ê½
$(document).ready(function (){
$('#send_ajax').click(function (){ //Ö±½Ó°ÑonclickʼþдÔÚÁËJSÖУ¬¶ø²»ÐèÒª»ìÔÚXHTMLÖÐÁË
      var params=$('input').serialize(); //ÐòÁл¯±íµ¥µÄÖµ£¬ÓëprototypeÖеÄform.serialize()Ïàͬ
      $.ajax({
            url £º'ajax_test.php',  //ºǫ́´¦Àí³ÌÐò
            type:'post', //Êý¾Ý·¢ËÍ·½Ê½
            dataType:'json', //½ÓÊ


Ïà¹ØÎĵµ£º

Ajax¶¨Ê±Ë¢ÐÂÒ³Ãæ

var xmlHttp;
var flag = false;
function createXMLHttpRequest()
{
  if(window.ActiveXObject)
  {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if(window.XMLHttpRequest)
  {
  xmlHttp=new XMLHttpRequest();
  }
}
fu ......

jqueryÖÐajaxÒì²½·µ»ØÊý¾Ý¸ñʽ×ܽá


dataÀàÐÍ
js´úÂ룺
$.post("getmaterial.do?method=getmaterial",
{name:name},
function (data) {
});
ÆäÖÐgetmaterial.do?method=getmaterialÊÇÇëÇóµÄurl£¬{name:name}ÊÇ´«µÝµ½ºǫ́µÄ²ÎÊý£¬¿ÉÒÔÓÃ
request.getParameter("name");»ñÈ¡£¬dataÊǺǫ́´«µÝ¹ýÀ´µÄÊý¾Ý¡£
action´úÂ룺
response.setContentType( ......

·¢Ò»¶ÎAjaxµÄ´úÂë

AjAx.js
   var bCheckUserPass = false;
   var StrType;
   function checkUsers(StrTmp)
   {
    var oB = window.document.all.nam
    StrType=StrTmp
    if (oB.length == 0) re ......

ÓÃAJAXµ÷ÓÃXMLʱ¾¹È»²»ÄÜ°üº¬ÈκηûºÅ

ÎÒÓÃActiveXObject("Microsoft.xmldom")À´×°ÔØxmlÎĵµÊ±£¬¾¹È»ÀÏÊÇÌáʾװÔØʧ°Ü£¬ºóÀ´ÉÏÍøËÑË÷ÁËÏ£¬ËµÊDz»ÄÜÖ±½Ó°üº¬Õâ5¸ö·ûºÅ£¨'><&"£©£¬±ØÐëÑ¡ÓÃ&xx;·½Ê½À´×ªÒ壬¿ÉÎÒÕÒ±éXMLҲû·¢ÏÖÕâЩ¡£
ºóÀ´ÎÒ¶ÀÐÐÅųý£¬²Å·¢ÏÖÓÐÒ»¸öÔªËصÄÊôÐÔֵΪÓГ|”£¬È¥³ýºó¾ÍÕý³£ÁË¡£ÎÒÕæÊǾõµÃÆæ¹Ö£¬ÍøÉÏҲûÓÐ˵ ......

ajaxʹÓÃPOST·½·¨Ìá½»±íµ¥

ajaxÖÐʹÓÃpost ·½Ê½Ìá½»±íµ¥Ê±ÄÜÌá½»¶à´ï2GBµÄÄÚÈÝ,¶øGET·½·¨Ö»ÄÜÌá½»×î¶à512KBµÄÄÚÈÝ.ÒÔÏÂÊÇajax POSTÌá½»µÄÀý×Ó.
<!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& ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ