AjaxÖÐsend·½·¨²ÎÊýµÄʹÓÃ
AjaxÖÐsend·½·¨²ÎÊýµÄʹÓÃ
Ò»°ãÇé¿öÏ£¬Ê¹ÓÃAjaxÌá½»µÄ²ÎÊý¶àÊÇЩ¼òµ¥µÄ×Ö·û´®£¬¿ÉÒÔÖ±½ÓʹÓÃGET·½·¨½«ÒªÌá½»µÄ²ÎÊýдµ½open·½·¨µÄurl²ÎÊýÖУ¬´Ëʱsend·½·¨µÄ²ÎÊýΪnull¡£
ÀýÈç £º
var url = "login.jsp?user=XXX&pwd=XXX";
xmlHttpRequest.open("GET",url,true);
xmlHttpRequset.send(null);
´ËÍ⣬Ҳ¿ÉÒÔʹÓÃsend·½·¨´«µÝ²ÎÊý¡£Ê¹ÓÃsend·½·¨´«µÝ²ÎÊýʹÓõÄÊÇPOST·½·¨£¬ÐèÒªÉ趨Content-TypeÍ·ÐÅÏ¢£¬Ä£ÄâHTTP POST·½·¨·¢ËÍÒ»¸ö±íµ¥£¬ÕâÑù·þÎñÆ÷²Å»áÖªµÀÈçºÎ´¦ÀíÉÏ´«µÄÄÚÈÝ¡£²ÎÊýµÄÌá½»¸ñʽºÍGET·½·¨ÖÐurlµÄд·¨Ò»Ñù¡£ÉèÖÃÍ·ÐÅϢǰ±ØÐëÏȵ÷ÓÃopen·½·¨¡£
ÀýÈ磺
xmlHttpRequest.open("POST","login.jsp",true);
xmlHttpRequest.setRequestHeder("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
xmlHttpRequest.send("user="+username+"&pwd="+password);
ÐèҪעÒâµÄÊǸù¾ÝÌá½»·½Ê½µÄ²»Í¬£¬Á½ÖÖÌá½»·½Ê½·Ö±ðµ÷Óúǫ́µÄdoGet·½·¨ºÍdoPost·½·¨¡£
Ïà¹ØÎĵµ£º
1.´´½¨XMLHttpRequest¶ÔÏó£º
function newXMLHttpRequest() {
var requestObj;
if (window.XMLHttpRequest) {
// Non IE
requestObj = new ActiveObj('XMLHttpRequest');
} else {
//IE
requestObj = new ActiveObj('Microsoft.XMLHTTP');
}
return request ......
ÔÚajaxû³öÀ´Ö®Ç°£¬Ò»Ö±ÊÇÓÃiframeʵÏÖµÄÎÞË¢ÐÂÇëÇó¡£
Ö÷ÒªµÄÔÀíÊÇ£º
ʹÓÃjs´´½¨Ò»¸öÒþ²ØµÄiframe
°ÑÒªÌá½»µÄ±íµ¥µÄtargetÊôÐÔÖ¸Ïò1ÖÐÉú³ÉµÄiframe
ÔÚÇëÇóµÄÒ³ÃæÖлص÷¸¸Ò³ÃæµÄ·½·¨
ÕâÑù¾ÍʵÏÖÁËÒ»¸ö¼òµ¥µÄ“Òì²½Ìá½»”
¿´ÆðÀ´ºÍajaxÒ»ÑùµÄЧ¹û£¬ÄÇΪʲô»¹ÒªÓÐajax£¬ÎÒÃÇÀ´±È½ÏÏ£º£¨ÒÔÏ°Ñajax¼¼Êõ³ÆΪX ......
WebÏîÄ¿ÖÐ×ÜÊÇ»áÓõ½Òì²½²Ù×÷£¬ÏÖÔÚµÄÒì²½²Ù×÷¿ÉÒÔÓø÷ÖÖ¸÷ÑùµÄ¿Ø¼þÀ´ÊµÏÖ£¬µ«ÊµÏÖÔÀí»¹ÊÇÒ»ÑùµÄ£¬±¾È˸üϲ»¶Ê¹ÓÃ×îÔʼµÄAjax²Ù×÷ȥʵÏÖÒì²½´¦Àí£¬±¾ÎĽöÏ׸øÄÇЩϲ»¶ÊµÏÖAjaxºÍÏîÄ¿ÖÐÒªÓõ½AjaxµÄÅóÓÑ¡£
AjaxʵÏÖÔÀí¾ÍÊÇ¿Í»§¶Ëͨ¹ýjavascript²Ù×÷µ÷Ó÷ ......
AjaxµÄÈ«³ÆÊÇ£ºAsynchronousJavaScript+XML
2.AjaxµÄ¶¨Ò壺
Ajax²»ÊÇÒ»¸ö¼¼Êõ£¬Ëüʵ¼ÊÉÏÊǼ¸ÖÖ¼¼Êõ£¬Ã¿ÖÖ¼¼Êõ¶¼ÓÐÆä¶ÀÌØÕâ´¦£¬ºÏÔÚÒ»Æð¾Í³ÉÁËÒ»¸ö¹¦ÄÜÇ¿´óµÄм¼Êõ¡£
3.Ajax°üÀ¨£º
XHTMLºÍCSS
ʹÓÃÎĵµ¶ÔÏóÄ£ÐÍ(DocumentObjectModel)×÷¶¯Ì¬ÏÔʾºÍ½»»¥
ʹÓÃXMLºÍXSLT×öÊý¾Ý½»»¥ºÍ²Ù×÷
ʹÓÃXMLHttpRequest½øÐÐÒ ......
XMLHttpRequest ¶ÔÏóÊÇAJAX¹¦ÄܵĺËÐÄ£¬Òª¿ª·¢AJAX³ÌÐò±ØÐë´ÓÁ˽âXMLHttpRequest ¶ÔÏó¿ªÊ¼¡£
¡¡¡¡Á˽âXMLHttpRequest ¶ÔÏó¾ÍÏÈ´Ó´´½¨XMLHttpRequest ¶ÔÏó¿ªÊ¼£¬ÔÚ²»Í¬µÄä¯ÀÀÆ÷Öд´½¨XMLHttpRequest ¶ÔÏóʹÓò»Í¬µÄ·½·¨£º
¡¡¡¡ÏÈ¿´¿´IE´´½¨XMLHttpRequest ¶ÔÏóµÄ·½·¨(·½·¨1)£º
¡¡¡¡var xmlhttp = new ActiveXObject(" ......