AJAX¿çÓò·ÃÎʳöÏÖ\&am#039;ûÓÐȨÏÞ\&am#039;µÄ´íÎó_Ajax±à³Ì_ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØ--Powered by WWW.RONGSEN.COM.CN

AJAX¿çÓò·ÃÎʳöÏÖ\&am#039;ûÓÐȨÏÞ\&am#039;µÄ´íÎó

×÷ÕߣººÚ¿Í·ÀÏßÍø°²Ajax½Ì³Ì»ùµØ À´Ô´£ººÚ¿Í·ÀÏßÍø°²Ajax½Ì³Ì»ùµØ ä¯ÀÀ´ÎÊý£º0

±¾Æª¹Ø¼ü´Ê£ºÈ¨ÏÞ´íÎóûÓгöÏÖ
ºÚ¿Í·ÀÏßÍø°²ÍøѶ£ººÜ¶àÈËÔÚʹÓÃAJAXµ÷ÓñðÈËÕ¾µãÄÚÈݵÄʱºò,JS»áÌáʾ"ûÓÐȨÏÞ"´íÎó£¬ÕâÊÇXMLHTTP×é¼þµÄÏÞÖÆ-°²È«Æð¼û½ûÖ¹·ÃÎÊ·ÇͬÓòµÄÍøÕ¾,ÏÂÃæÒ»¸öÀý×ÓÀ´·ÃÎÊhttp://www.google.cn,<script type="text/java...

ºÜ¶àÈËÔÚʹÓÃAJAXµ÷ÓñðÈËÕ¾µãÄÚÈݵÄʱºò,JS»áÌáʾ"ûÓÐȨÏÞ"´íÎó£¬ÕâÊÇXMLHTTP×é¼þµÄÏÞÖÆ-°²È«Æð¼û½ûÖ¹·ÃÎÊ·ÇͬÓòµÄÍøÕ¾,ÏÂÃæÒ»¸öÀý×ÓÀ´·ÃÎÊhttp://www.google.cn,

<script type="text/javascript"> function createobj() {  if (window.ActiveXObject) {           return new ActiveXObject("Microsoft.XMLHTTP");       }       else if (window.XMLHttpRequest) {           return new XMLHttpRequest();       }  }   function getWebPage(url) {    var oBao=createobj();    var my_url=url    oBao.open('get',my_url,false);     oBao.onreadystatechange=function(){         if(oBao.readyState==4){              if(oBao.status=<script type="text/javascript"> function createobj() {  if (window.ActiveXObject) {           return new ActiveXObject("Microsoft.XMLHTTP");       }       else if (window.XMLHttpRequest) {           return new XMLHttpRequest();       }  }   function getWebPage(url) {    var oBao=createobj();    var my_url=url    oBao.open('get',my_url,false);     oBao.onreadystatechange=function(){         if(oBao.readyState==4){              if(oBao.status==200){                var returnStr=oBao.responseText;                document.write(returnStr);              }else{                document.write("δÕÒµ½ÄúÊäÈëµÄµØÖ·»ò·þÎñÆ÷505´íÎó!");              }         }    }    oBao.send(null);   }  getWebPage('http://www.google.cn');  </script> =200){                var returnStr=oBao.responseText;                document.write(returnStr);              }else{                document.write("δÕÒµ½ÄúÊäÈëµÄµØÖ·»ò·þÎñÆ÷505´íÎó!");              }         }    }    oBao.send(null);   }  getWebPage('http://www.google.cn');  </script> ±£´æÕâ¶Î´úÂëµ½test.html,ÔÚ±¾µØÖ±½ÓÓÃIE´ò¿ªÃ»ÎÊÌâ,µ«½«¸Ã¶Î´úÂëÉÏ´«µ½·þÎñÆ÷ºó£¬ÎÊÌâ³öÏÖÁË--JSÌáʾ"ûÓÐȨÏÞ"´íÎó!!!Õâ¸ÃÈçºÎ½â¾öÄØ£¿

ÏÂÃæ˼¿¼Ò»Ï£º¼ÈÈ»²»ÄÜ·ÃÎÊ·ÇͬÓòµÄ£¬Ö»ÄÜ·ÃÎÊͬÓòµÄµØÖ·ÁË£¬Í¬ÓòµÄ¶¯Ì¬ÎļþÔõô»ñÈ¡·ÇͬÓòÍøÒ³ÄÚÈÝÄØ£¿ÎÒÃÇ»¹ÊÇÏëµ½µÄAJAX£¬Ö»²»¹ýÕâ¸öAJAXÊÇÔÚ·þÎñÆ÷¶ËÖ´ÐÐ.

´óÌå˼·ÊÇÕâÑùµÄ:Ê×ÏȽ«URLÓÃAJAXÌá½»¸ø×Ô¼ºÕ¾ÄÚµÄÎļþ£¬ÀýÈçgetPage.asp---ÔÚgetPage.aspÔÙ´Îͨ¹ý·þÎñÆ÷XMLHTTPÀ´·ÃÎÊÌá½»À´µÄURL---½«»ñÈ¡µÄÄÚÈÝ·µ»Ø¸øÌá½»URLµÄÒ³----ÏÔʾÄÚÈÝ

ÏÂÃ濪ʼ×éÖ¯´úÂë,Ê×ÏÈÊÇtest.htmlÎļþ

<script type="text/javascript"> function createobj() {  if (window.ActiveXObject) {           return new ActiveXObject("Microsoft.XMLHTTP");       }       else if (window.XMLHttpRequest) {           return new XMLHttpRequest();       }  }   function getWebPage(url) {    var oBao=createobj();    var my_url="getpage.asp?url="+escape(url);    oBao.open('get',my_url,false);     oBao.onreadystatechange=function(){         if(oBao.readyState==4){              if(oBao.status==200){                var returnStr=oBao.responseText;                document.write(returnStr);              }else{                document.write("δÕÒµ½ÄúÊäÈëµÄµØÖ·»ò·þÎñÆ÷505´íÎó!");              }         }    }    oBao.send(null);   }  getWebPage('http://www.google.cn');  </script>  ÔÙ¾ÍÊÇgetpage.aspÎļþ(×¢Òâ:ÒªÒÔUTF-8¸ñʽ±£´æ±¾Îļþ,·ÀÖ¹ÂÒÂë),ÈçÏÂ:    <%  response.charset="UTF-8" reg="\<meta.+ charset= {0,}([^\"" \>\/]*).+\/{0,1}\>" 'º¯ÊýÃû:GetResStr  '×÷ÓÃ:»ñÈ¡Ö¸¶¨URLµÄHTML´úÂë  '²ÎÊý:URL-Òª»ñÈ¡µÄURL  function GetResStr(URL)  err.clear  dim ResBody,ResStr,PageCode,ReturnStr  Set Http=createobject("MiCROSOFT.XMLHTTP")   Http.open "GET",URL,False   Http.Send()   If Http.Readystate =4 Then     If Http.status=200 Then      ResStr=http.responseText      ResBody=http.responseBody      PageCode=GetCode(ResStr,reg)      ReturnStr=BytesToBstr(http.responseBody,PageCode)      GetResStr=ReturnStr   End If   End If   End Function   'º¯ÊýÃû:BytesToBstr  '×÷ÓÃ:ת»»¶þ½øÖÆÊý¾ÝΪ×Ö·û  '²ÎÊý:Body-¶þ½øÖÆÊý¾Ý,Cset-Îı¾±àÂ뷽ʽ  Function BytesToBstr(Body,Cset)     Dim Objstream     Set Objstream = CreateObject("adodb.stream")     objstream.Type = 1     objstream.Mode =3     objstream.Open     objstream.Write body     objstream.Position = 0     objstream.Type = 2     objstream.Charset =Cset     BytesToBstr = objstream.ReadText     objstream.Close     set objstream = nothing   End Function   'º¯ÊýÃû:GetCode  '×÷ÓÃ:ת»»¶þ½øÖÆΪ×Ö·û  '²ÎÊý:str-´ý²éѯ×Ö·û´®,regstr-ÕýÔò±í´ïʽ  Function GetCode(str,regstr)  Dim Reg,serStr  set Reg= new RegExp  Reg.IgnoreCase = True Reg.MultiLine = True Reg.Pattern =regstr if Reg.test(str) then 'Èô²éѯµ½Æ¥ÅäÏî     Set Cols = Reg.Execute(str)     serStr=Cols(0).SubMatches(0) 'ʹÓÃÆ¥Åäµ½µÄµÚÒ»¸öÆ¥ÅäÏî  else '·ñÔò¸ø¸öĬÈÏÖµgb2312,ÓеãÊ¡ÀÁ·¨£¬Èç¹ûÒ³Ãæû¸ø³ö±àÂë¸ñʽ£¬ÏëÖªµÀȷʵÓеãÂé·³     serStr="gb2312" end if  GetCode=serStr end function   dim url:url=request.querystring("url")  response.write GetResStr(URL)  %> ´úÂë×éÖ¯Íê±Ï,ʵÑéÏÂ,³É¹¦ÌáÈ¡http://www.google.cnµÄÄÚÈÝ!!!!!ÕâÑù¾Í¿ÉÒÔ½â¾ö"ûÓÐȨÏÞ"µÄÎÊÌâÁË¡£ Æäʵ,µ¥´¿Ò»¸ögetpage.aspÒ»ÑùÄÜ»ñÈ¡£¬²»¹ý²»ÄÜÏñjsÄÇÑù¶¯Ì¬µÄ´¦ÀíDOM¡£

»¹ÓÐÒ»¸öÎÊÌâ,Èç¹ûÄãÓõÚÒ»ÖÖ·½·¨·ÃÎÊhttp://www.baidu.com»á³öÏÖÂÒÂë,ÒòΪbaidu±àÂëΪGB2312,¶øXMLHTTP·µ»ØµÄÊÇUTF-8±àÂë¸ñʽ¡£ÓõڶþÖÖ·½·¨¾Í²»»á³öÏÖÕâÑùµÄÎÊÌâÁË,Ö»Òª¶¨ÒåÁ˱àÂë¸ñʽµÄÕ¾µã¾ÍÄÜÕý³£·µ»ØÐÅÏ¢(ÕâÀï²»ÄÜ°üÀ¨Ò»Ð©Ê¹ÓÃÌرð±àÂëµÄÕ¾µã)¡£

    ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤·½°¸±¾ÆªÁ¬½Ó£ºhttp://www.rongsen.com.cn/show-15687-1.html
Íøվά»¤½Ì³Ì¸üÐÂʱ¼ä:2012-04-05 00:05:32  ¡¾´òÓ¡´ËÒ³¡¿  ¡¾¹Ø±Õ¡¿
ÎÒÒªÉêÇë±¾Õ¾£ºNµã | ºÚ¿Í·ÀÏß¹ÙÍø |  
רҵ·þÎñÆ÷ά»¤¼°Íøվά»¤ÊÖ¹¤°²È«´î½¨»·¾³£¬ÍøÕ¾°²È«¼Ó¹Ì·þÎñ¡£ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØÕÐÉ̽øÐÐÖУ¡QQ:29769479

footer  footer  footer  footer