ajax¼ò½é
1.´´½¨XMLHttpRequest¶ÔÏó£º
function newXMLHttpRequest() {
var requestObj;
if (window.XMLHttpRequest) {
// Non IE
requestObj = new ActiveObj('XMLHttpRequest');
} else {
//IE
requestObj = new ActiveObj('Microsoft.XMLHTTP');
}
return requestObj;
}
2.ÉèÖÃÔÚÇëÇó¹ý³ÌÖÐ״̬·¢Éú±ä»¯Ê±Òªµ÷Óõĺ¯Êý£¬µ±È»Õâ¸ö¹ý³ÌÖÐËü»á±»µ÷Óúü¸´Î£º
var xmlRequest;
xmlRequest = newXMLHttpRequest();
xml.onreadystatechange = callbackhandler;
ÔÚ·¢Ë͹ý³ÌÖлáÓÐ5ÖÖ״̬µÄת»»£º
״̬Êý×ÖÂëÃèÊö
0
δ³õʼ»¯×´Ì¬¡£ÕâÊÇÔÚ¿ªÊ¼²Ù×÷֮ǰreadyStateÓò×î³õµÄÖµ
1
ÕýÔÚ¼ÓÔØ״̬¡£ËüÒâζ×Åopen()·½·¨±»µ÷ÓÃÁË£¬µ«»¹Ã»Óе÷ÓÃsend()·½·¨
2
ÒѾ¼ÓÔØ״̬¡£ËüÒâζ×Åsend()·½·¨±»µ÷Ó㬲¢ÇÒ¶ÔÏóÒѾÍê³ÉÇëÇóÁË£¬µ«ÊÇ»¹Ã»ÓнÓÊÕµ½Êý¾Ý£¬´ËʱͷÐÅÏ¢ºÍ״̬ÊÇ¿ÉÓõÄ
3
ÕýÔÚ½ÓÊÕ(»òÕß˵½»»¥)״̬¡£´ËʱÊý¾ÝÕýÔÚ½ÓÊÕÖУ¬reponseTextÖд洢×ŵ½Ä¿Ç°ÎªÖ¹½ÓÊܵ½µÄÊý¾Ý
4
½»»¥Íê³É״̬¡£ÇëÇóÒѾÍê³É²¢ÇÒÒѾ½ÓÊÕµ½ÍêÕûµÄÏìÓ¦
3.µ÷ÓÃopen·½·¨¸æË߶ÔÏóÏëµ÷ÓÃʲôURLÀ´´¦ÀíÕâ´ÎÇëÇó£¬ËüÓÐÈý¸ö²ÎÊý£¬µÚÒ»¸ö²ÎÊýÊÇÓÃÀ´Ö¸¶¨Ê¹ÓÃʲôhttp·½·¨(post¡¢getµÈ)£¬µÚ¶þ¸ö¾ÍÊÇÒªÖ´ÐеÄurl£¬µÚÈý¸ö²ÎÊýÊÇbooleanÀàÐÍ£¬¸æË߶ÔÏóÊÇ·ñÐèÒªÒì²½Ö´Ðе÷Óã¬Ò»°ã¶¼ÊÇtrue£º
XMLRequest.open("post", url, true);
4.µ÷ÓÃsend()À´ÉèÖÃÒª·¢Ë͵½·þÎñÆ÷¶ËµÄÊý¾Ý£¬×¢Òâ´Ëʱ·¢Ë͵ÄÊý¾Ý×îºÃʹÓÃencodeURIComponent() ·½·¨½øÐбàÂ룬·ñÔòÏñ¿Õ¸ñÕâÀàµÄ×Ö·û¾Í»á³öÏÖÂÒÂ룺
XMLRequest.send('value1=' + encodeURIComponent(value1) + '&value2=' + encodeURIComponent(value2));
ÔÚ״̬ת»»Ê±´¦ÀíµÄº¯ÊýÖÐÖ»ÒªÅжÏreadyState = 4ʱ¼´¿É£¬µ±È»Õâ¸öº¯Êý¿ÉÒÔ½øÒ»²½·Ö½â£¬ÔÚÀïÃæ°ü×°XMLµÄÑéÖ¤µÈ²Ù×÷¡£×Ô¼ºÂýÂýÈ¥Ñо¿°É¡£
Ïà¹ØÎĵµ£º
»ùÓÚJQuery¿ò¼ÜµÄAJAX
Ç°¼¸Ìì·¢Á˸öÌù£¬·ÖÏíÁËprototype¿ò¼Ü¹ØÓÚAJAX·½ÃæµÄѧϰ¹ý³Ì¡£È»ºóÓÐÈË˵jquery¿ò¼Ü¸ü·½±ã¡£
ÕýºÃÏîÄ¿ÖÐ×¼±¸Ê¹ÓÃthickbox£¬ÓÚÊǸɴàÅ×Æúprototype.js£¬¿´Æðjquery.jsÁË¡£JQueryȷʵ²»´í£¬Ìå»ý±È PrototypeСÁËÐí¶à£¬¶øÇÒʹÓÃÆðÀ´¸ü·½±ã¸üÁé»î¡£ÓÐÈË˵PrototypeÏñJAVA£¬Õýͳ£»¶øJQueryÏñRuby£¬Áé»î£ ......
function eidtPageCheckIsOrder ( serverid ){
var telephonenum = document.formx.TELPHONENUM.value;
var webWapFlag=document.formx.WEBORWAPFLAG.value;
var param=setPisaQueryString('TELPHONENUM',telephonenum,'WEBORWAPFLAG',webWapFlag,'serverid',serverid,'destFold ......
ÍøÒ³ÖгöÏÖ“'sys' 䶨Òå
”»ò“'Sys' is undefined”µÄ´íÎó¡£
´ËʱÎÒÃÇÒª×öµÄÊÇÔÚ web.config
ÖÐ <system.web> Ò»½ÚÏÂÃæÌí¼ÓÀàËÆ
ÈçÏÂÄÚÈÝ£º
<httpHandlers>
<add
verb="GET,HEAD" path="ScriptResource.a ......
<script type="text/javascript" src="jquery-1.3.2.min.js" mce_src="js/jquery.js"></script>
<input name="writer" id="writer" type="text" value="" />
<input name="pass" id="pass" type="password" value="" /> ......
ajax¿çÓòºÍJSµÄ¿çÓòͨÐÅ(Cross The Site)µÄ¼¸ÖÖ½â¾ö·½°¸
×î½ü×öµÄÒ»¸öÏîÄ¿ÖÐÐèÒªajax¿çÓòÈ¡µÃÊý¾Ý,Èç¹ûÊÇÔÚ±¾ÓòÖÐȷʵûÓÐÎÊÌ⣬µ«ÊǷŵ½¶þ¼¶ÓòºÍÆäËûÓòÏÂä¯ÀÀÆ÷Ö±½Ó¾Íµ¯³öÌáʾ¿ò:“¸ÃÒ³ÕýÔÚ
1.ʲôÒýÆðÁËajax¿çÓò²»ÄܵÄÎÊÌâ
ajax±¾Éíʵ¼ÊÉÏÊÇͨ¹ýXMLHttpRequest¶ÔÏóÀ´½øÐÐÊý¾ÝµÄ½»»¥£¬¶øä¯ÀÀÆ÷ ......