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

ʹÓÃXMLHttpRequest ʵÏÖajaxЧ¹û

Ò»¡¢XMLHttpRequest ¶ÔÏóµÄ·½·¨ÓëÊôÐÔ
·½    ·¨
Ãè    Êö
abort()
Í£Ö¹µ±Ç°ÇëÇó
getAllResponseHeaders()
°ÑHTTPÇëÇóµÄËùÓÐÏìÓ¦Êײ¿×÷Ϊ¼ü/Öµ¶Ô·µ»Ø
getResponseHeader("header")
·µ»ØÖ¸¶¨Êײ¿µÄ´®Öµ
open("method", "url")
½¨Á¢¶Ô·þÎñÆ÷µÄµ÷Óá£method²ÎÊý¿ÉÒÔÊÇGET¡¢POST»òPUT¡£url²ÎÊý¿ÉÒÔÊÇÏà¶ÔURL»ò¾ø¶ÔURL¡£Õâ¸ö·½·¨»¹°üÀ¨3¸ö¿ÉÑ¡µÄ²ÎÊý
send(content)
Ïò·þÎñÆ÷·¢ËÍÇëÇó
setRequestHeader("header", "value")
°ÑÖ¸¶¨Êײ¿ÉèÖÃΪËùÌṩµÄÖµ¡£ÔÚÉèÖÃÈκÎÊײ¿Ö®Ç°±ØÐëÏȵ÷ÓÃopen()
  Êô  ÐÔ
Ãè    Êö
onreadystatechange
ÿ¸ö״̬¸Ä±äʱ¶¼»á´¥·¢Õâ¸öʼþ´¦ÀíÆ÷£¬Í¨³£»áµ÷ÓÃÒ»¸öJavaScriptº¯Êý
readyState
ÇëÇóµÄ״̬¡£ÓÐ5¸ö¿ÉÈ¡Öµ£º0 = δ³õʼ»¯£¬1 = ÕýÔÚ¼ÓÔØ£¬2 = ÒѼÓÔØ£¬3 = ½»»¥ÖУ¬4 = Íê³É
responseText
·þÎñÆ÷µÄÏìÓ¦£¬±íʾΪһ¸ö´®
responseXML
·þÎñÆ÷µÄÏìÓ¦£¬±íʾΪXML¡£Õâ¸ö¶ÔÏó¿ÉÒÔ½âÎöΪһ¸öDOM¶ÔÏó
status
·þÎñÆ÷µÄHTTP״̬Â루200¶ÔÓ¦OK£¬404¶ÔÓ¦Not Found£¨Î´ÕÒµ½£©£¬µÈµÈ£©
statusText
HTTP״̬ÂëµÄÏàÓ¦Îı¾£¨OK»òNot Found£¨Î´ÕÒµ½£©µÈµÈ£©
¶þ¡¢Ê¹ÓÃXMLHttpRequest ʵÏÖajaxЧ¹û
ÕâÀïÎÒÃÇÓÿͻ§¶Ëͨ¹ýXMLHttpRequest ÇëÇó·þÎñ¶Ë»ñÈ¡µ±Ç°ÏµÍ³Ê±¼ä£¬ÊµÏÖÒì²½½»»¥£¡
¿Í»§¶ËmyAjax.html´úÂë
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>xmlhttprequest ajax demo</title>
<mce:script type ="text/javascript" language ="javascript" ><!--
var req; //¶¨Òå±äÁ¿£¬ÓÃÀ´´´½¨xmlhttprequest¶ÔÏó
function creatReq() // ´´½¨xmlhttprequest,ajax¿ªÊ¼
{
var url="ajaxServer.aspx"; //ÒªÇëÇóµÄ·þÎñ¶ËµØÖ·
if(window.XMLHttpRequest) //·ÇIEä¯ÀÀÆ÷¼°IE7(7.0¼°ÒÔÉÏ°æ±¾)£¬ÓÃxmlhttprequest¶ÔÏó´´½¨
{
req=new XMLHttpRequest();
}
else if(window.ActiveXObject) //IE(6.0¼°ÒÔÏ°汾)ä¯ÀÀÆ÷ÓÃactivexobject¶ÔÏó´´½¨,Èç¹ûÓû§ä¯ÀÀÆ÷½ûÓÃÁËActiveX,¿ÉÄÜ»áʧ°Ü.
{
req=new ActiveXObject("Microsoft.XMLHttp");
}

if(req) //³É¹¦´´½¨xmlhttprequest
{
req


Ïà¹ØÎĵµ£º

AJAX¿ò¼Ü/RIA ¹²ÊÕ¼ÁË 57 ¸ö JavaScript ÏîÄ¿


Ajax¿ò¼Ü jQuery
jQueryÊÇÒ»¿îÃâ·ÑÇÒ¿ª·ÅÔ´´úÂëµÄJavaScript´úÂë¿â£¬ÓÉJohn Resig´´½¨¡£ÊÚȨЭÒéΪGPLºÍMITÐí¿É֤˫ЭÒ顣ʾÀý´úÂ룺 $("p.neat").addClass("ohmy").show("slow"); ÌصãÇáÁ¿¼¶¾­GZipѹËõºó´«ÊäµÄ´úÂëÎļþ½ö14KB£¬Î´¾­Ñ¹Ëõ´«Ë͵ĴúÂëÎļþ½ö26KB¡£ jQuery 1.26°æʱ£º µµ°¸µµ°¸ÐÐÊýµµ°¸Size ±¸×¢ jquery-1.2 ......

Ajax ½øÐÐPost´«ÖµºÍGet´«Öµ £¨¾­µä£©

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script language="javascript">
function saveUserInfo()
{
//»ñÈ¡½ÓÊÜ·µ»ØÐÅÏ¢²ã
var msg = document.getElementById("msg");
//»ñÈ¡±íµ¥¶ÔÏóºÍÓ ......

php ajax mysql±àÂëgb2312

 1¡¢PHP·¢ËÍÖÐÎÄ¡¢Ajax½ÓÊÕ
Ö»ÐèÔÚphp¶¥²¿¼ÓÈëÒ»¾ä£º
header('Content-type: text/html;charset=GB2312');
xmlHttp»áÕýÈ·½âÎöÆäÖеÄÖÐÎÄ¡£
2¡¢Ajax·¢ËÍÖÐÎÄ¡¢PHP½ÓÊÕ
Õâ¸ö±È½Ï¸´ÔÓ£º
AjaxÖÐÏÈÓÃencodeURIComponent¶ÔÒªÌá½»µÄÖÐÎĽøÐбàÂë
PHPÖУº
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//I ......

ajaxÈýÑÔÁ½Óï(Ö±½Ó½«xmlhttp·µ»ØÖµ½øÐÐjs´úÂë´¦Àí)


ÕâÀïµÄajax¿É²»ÊÇ´óÃû¶¦¶¦µÄajax¾ãÀÖ²¿£¬ ÕâËĸö×ÖĸÔÚÕâÀïAsynchronous JavaScript and XMLµÄËõд¡£Í¨Ë×µØÃèÊöÕâÏî¼¼Êõ¾ÍÊÇ£ºÓà JavaScript Ïò·þÎñÆ÷»ñÈ¡Êý¾Ý£¬È»ºó¸üÐÂÍøÒ³µÄ¾Ö²¿£¬¶ø²»ÊÇË¢ÐÂÕû¸öÍøÒ³¡£
ÕâÏî¼¼Êõ·Ç³£ÊʺÏÓÃÀ´¿ª·¢ÒÔä¯ÀÀÆ÷Ϊ¿Í»§¶ËµÄϵͳµÄ½çÃ棬ʹÓÃajax¸øÓû§´øÀ´µÄ¸üºÃµÄÌåÑ飬ËûÃDz»»á¸Ð¾õµ½ÓÃä¯À ......

ʹÓà jQuery ¼ò»¯ Ajax ¿ª·¢

jQuery ÊÇÒ»¸öJavaScript ¿â£¬ËüÓÐÖúÓÚ¼ò»¯ JavaScript™ ÒÔ¼° Asynchronous JavaScript + XML (Ajax) ±à³Ì¡£ÓëÀàËÆµÄ JavaScript ¿â²»Í¬£¬jQuery ¾ßÓжÀÌصĻù±¾Ô­Àí£¬¿ÉÒÔ¼ò½àµØ±íʾ³£¼ûµÄ¸´ÔÓ´úÂ롣ѧϰ jQuery »ù±¾Ô­Àí£¬Ì½Ë÷ÆäÌØÐԺ͹¦ÄÜ£¬Ö´ÐÐһЩ³£¼ûµÄ Ajax ÈÎÎñ²¢ÕÆÎÕÈçºÎʹÓòå¼þÀ©Õ¹ jQuery¡£
jQuery ÊÇʲ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ