Ajax±àÂëºÍAjaxÂÒÂë½â¾ö
AJAXÂÒÂë½â¾ö
ÓùýAJAXµÄÅóÓѿ϶¨ÖªµÀjavascriptÊÇʹÓÃUTF-8¹ú¼Ê±àÂ룬¼´Ã¿¸öºº×ÖÓÃ4¸ö×Ö½ÚÀ´´æ´¢£¬µ«ÊÇÕâ¾ÍÔì³ÉÁËÓÃAJAXÀ´sendÊý¾ÝµÄʱºò³öÏÖÂÒÂë¡£
AjaxÂÒÂë²úÉúÖ÷ÒªÓÐ2¸öÔÒò
1. xtmlhttp ·µ»ØµÄÊý¾ÝĬÈϵÄ×Ö·û±àÂëÊÇutf-8£¬Èç¹ûǰ̨ҳÃæÊÇgb2312»òÕßÆäËü±àÂëÊý¾Ý¾Í»á²úÉúÂÒÂë
2. post·½·¨Ìá½»Êý¾ÝĬÈϵÄ×Ö·û±àÂëÊÇutf-8£¬Èç¹ûºǫ́ÊÇgb2312»òÆäËû±àÂëÊý¾Ý¾Í»á²úÉúÂÒÂë
Ò»¡¢Ê¹ÓÃencodeURIComponent¼ÓÉÏÐÞ¸Ä Content-Type Ϊ application/x-www-form-urlencoded" À´°ÑÊý¾Ýͳһ±àÂë³É url ¸ñʽ£¬µ«ÊÇÕâÑù×öÓÐÒ»¸ö±×¶Ë£¬¾ÍÊÇÌ«´óµÄÊý¾ÝÍùÍù»á³ö´í¡£
¶þ¡¢ÊÇͨ¹ývbscript µÄдµÄº¯Êý°ÑÊý¾Ýת³Égb2312¸ñʽµÄ£¬ÎÒ¸öÈ˾õµÃÕâÖÖ·½·¨±È½ÏºÃ¡£ÓÐÐËȤµÄÅóÓÑ¿ÉÒÔµ½ÍøÉÏÈ¥²éһϡ£
Èý¡¢¿Í»§¶Ë¡¢·þÎñÆ÷¶ËÈ«²¿²ÉÓÃUtf-8±àÂ룬ÇÒurl·¢ËÍÖÐÎÄ×Ö²ÉÓÃescape±àÂë,unescape½âÂë¡£¶øÇÒЧÂʸß,¶øÇÒ·ûºÏÄ¿Ç°µÄÐÎʽ,utf-8±àÂë±¾Éí¾ÍÊÇÒ»ÖֱȽÏÓÅÐãµÄ±àÂë¡£
½ñÌìÍ»·¢ÆæÏ룬AJAXµ÷ÓõÄʱºò»á²»»á·¢ËÍcookie ÄØ£¿ÂíÉÏдÁËÒ»¸ö³ÌÐò²âÊÔһϣ¬¹ûÈ»ÄÜ£¬ÕâÑù¾Í¿ÉÒÔÔÚµ÷ÓÃajax֮ǰ£¬ÏÈ°ÑÊý¾Ýͨ¹ýjavascriptдµ½cookieÀȻºóÔÙsend¾Í¿ÉÒÔ½«cookieÀïµÄÊý¾Ý·¢ËͳöÈ¥ÁË£¬Ì«Ë¬ÁË£¡£¡
¿Í»§¶Ë´úÂë ajax.htm
<title>AJAXʹÓÃcookie´«ÖµÀý×Ó</title>
<script>
var oDiv
var xh
function getXML()
{
setcookie($('name').value,$('val').value);
oDiv = document.all.m
oDiv.innerHTML = "ÕýÔÚ×°ÔØ£¬ÇëÉԺ."
oDiv.style.display= ""
xh = new ActiveXObject("Microsoft.XMLHTTP")
xh.onreadystatechange = getReady
xh.open("POST","a.php",false)
xh.send();
}
function getReady()
{
if(xh.readyState==4)
{
if(xh.status==200)
{
&n
Ïà¹ØÎĵµ£º
×î½üÍøÉÏÌáµÄºÜ¶àµÄÒ»¸öиÅÄî¾ÍÊÇ AJAX ÁË, ÄÇô, AJAX ÊÇʲôÄØ? ÒÔÏÂÄÚÈÝÒýÓÃÍøÉÏ×ÊÁÏ:
AJAXÈ«³ÆΪ“Asynchronous JavaScript and XML”£¨Òì²½JavaScriptºÍXML£©£¬ÊÇÖ¸Ò»ÖÖ´´½¨½»»¥Ê½ÍøÒ³Ó¦ÓõÄÍøÒ³¿ª·¢¼¼Êõ¡£ËüÓлúµØ°üº¬ÁËÒÔϼ¸ÖÖ¼¼Êõ£º
Ajax£¨Asynchronous JavaScript + XML£©µÄ¶¨Òå
»ùÓÚ web±ê×¼£¨sta ......
var file = filefromPath(encodeURI(encodeURI(this._input.value)));//»ÆÓðÐÞ¸Ä 2010Äê4ÔÂ8ÈÕ //Ð޸ĺó
²»ºÃÒâ˼ÄÇÌìûÓÐÔÚIE²âÊÔ
  ......
JSÎļþ
//ÒÔÏÂΪjquery´úÂë
$(document).ready(function(){
$("#jqbtn").click(function(){
  ......
AJAX¼¼Êõ½éÉÜ
AJAX µÄÈ«³ÆÖ¸Òì²½µÄ JavaScript ¼° XML£¨Asynchronous JavaScript And XML£©
ÔÚѧϰAJAX֮ǰ£¬ÄãÐèÒªÁ˽âµÄ֪ʶÓУº
HTML / XHTML
JavaScript
µ±È»»¹ÓÐһЩÆäËûµÄ¼¼Êõ£ºCSS¡¢DOM¡¢XML¡¢XMLHttpRequest
AJAX ²»ÊÇÒ»ÖÖеıà³ÌÓïÑÔ£¬¶øÊÇÒ»ÖÖÓÃÓÚ´´½¨¸üºÃ¸ü¿ìÒÔ¼°½»»¥ÐÔ¸üÇ¿µÄ Web Ó¦ÓóÌÐòµÄ¼¼Êõ¡£
ͨ¹ ......
ÔÚAjax url´«²Îʱ³öÏÖÖÐÎÄÂÒÂëµÄÇé¿ö
Àý1: xmlHttp.open("GET","Engine.aspx?Action=getmainsort&Type=2&Parent="+escape("ÖÐÎÄ")+"&Stochastic=" + Math.random(),true);
µ«ÊÇÕâ¸öÖ»ÄÜÆÕͨµÄ<a href=''.ÓÐЧ¹û¡£Èç¹ûÊÇajax´«ÖµµÄ»°»¹ÊDz»ÐеÄ...ÓÐÈËÌá³ö:Òª ......