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·½·¨¡£
Ïà¹ØÎĵµ£º
ajax¿çÓòºÍJSµÄ¿çÓòͨÐÅ(Cross The Site)µÄ¼¸ÖÖ½â¾ö·½°¸
×î½ü×öµÄÒ»¸öÏîÄ¿ÖÐÐèÒªajax¿çÓòÈ¡µÃÊý¾Ý,Èç¹ûÊÇÔÚ±¾ÓòÖÐȷʵûÓÐÎÊÌ⣬µ«ÊǷŵ½¶þ¼¶ÓòºÍÆäËûÓòÏÂä¯ÀÀÆ÷Ö±½Ó¾Íµ¯³öÌáʾ¿ò:“¸ÃÒ³ÕýÔÚ
1.ʲôÒýÆðÁËajax¿çÓò²»ÄܵÄÎÊÌâ
ajax±¾Éíʵ¼ÊÉÏÊÇͨ¹ýXMLHttpRequest¶ÔÏóÀ´½øÐÐÊý¾ÝµÄ½»»¥£¬¶øä¯ÀÀÆ÷ ......
½ñÌìÎÒѧϰÁËÙ¡ÀÏʦ½²µÄajaxµÄ֪ʶ£º
Ò»¡¢ Ajax
a) ÔÊÐíä¯ÀÀÆ÷Óë·þÎñÆ÷ͨÐŶøÎÞÐëˢе±Ç°Ò³ÃæµÄ¼¼Êõ¶¼±»½Ð×öAjax¡£Êý¾ÝÔÚ¿Í»§¶ËÓë·þÎñÆ÷Ö®¼ä¶ÀÁ¢´«Êä¡£·þÎñÆ÷²»ÔÙ·µ»ØÕû¸öÒ³Ãæ
b) XMLHttpRequest£º¸Ã¶ÔÏ ......
ÔÚajaxû³öÀ´Ö®Ç°£¬Ò»Ö±ÊÇÓÃiframeʵÏÖµÄÎÞË¢ÐÂÇëÇó¡£
Ö÷ÒªµÄÔÀíÊÇ£º
ʹÓÃjs´´½¨Ò»¸öÒþ²ØµÄiframe
°ÑÒªÌá½»µÄ±íµ¥µÄtargetÊôÐÔÖ¸Ïò1ÖÐÉú³ÉµÄiframe
ÔÚÇëÇóµÄÒ³ÃæÖлص÷¸¸Ò³ÃæµÄ·½·¨
ÕâÑù¾ÍʵÏÖÁËÒ»¸ö¼òµ¥µÄ“Òì²½Ìá½»”
¿´ÆðÀ´ºÍajaxÒ»ÑùµÄЧ¹û£¬ÄÇΪʲô»¹ÒªÓÐajax£¬ÎÒÃÇÀ´±È½ÏÏ£º£¨ÒÔϰÑajax¼¼Êõ³ÆÎªX ......
ËÄ¡¢³£¼ûAjax±à³Ì¿ò¼Ü
¼ÈÈ»ÉÏÊöAjax¿ò¼ÜÒѾÄܹ¤×÷ÁË£¬ÎªÊ²Ã´»¹ÓÐÄÇô¶àµÄ¿ò¼ÜÄØ£¿
Ëæ×ÅÒ³ÃæµÄ¸´ÔÓ£¬¿ÉÄÜÐèÒªÊéд´óÁ¿µÄJavascript½Å±¾À´¶ÔÒ³ÃæÖеÄDOM¶ÔÏó½øÐпØÖÆ£¬¹¤×÷Á¿ºÍ¸´ÔÓ¶È»á´ó´óÔö¼Ó¡£Ajax±à³Ì¿ò¼Üͨ³£ÀûÓÃÃæÏò¶ÔÏóµÄ·½·¨£¬¶ÔһЩ»ù±¾µÄ¶ÔÏóºÍÐÐΪ¼° ......
ÎÊÌ⣺
µ±Óû§µã»÷ɾ³ý°´Å¥Ê±£¬³ÌÐòµ÷ÓÃResponse.write("<script>alert('ÊÇ·ñ¼ÌÐø')</script>")ÊÇÒ³Ãæ»áµ¯³ö´íÎó£º
Sys.WebForms.PageRequestManagerParserErrorException:The
message received from the server count not be parsed.Common causes for
this error are when ......