Because ajax has a title on cross-origin visits, the best way to do it is to act as a proxy and write a proxy program and experience. In order to act as an ajax proxy, I studied the xmlhttp on the server and compared it with the xmlhttp in the client's ajax. the background code is asp.
Because ajax has a title on cross-origin visits, the best way to do it is to act as a proxy and write a proxy program and experience.
In order to act as an ajax proxy, I studied the xmlhttp on the server and compared it with the xmlhttp in the client's ajax. the background code is asp.
The xmlhttp server is an asp thief program. I changed the code to javascript.
1. the xmlhttp. Open ("GET", url, false) asynchronization on the server must be closed, and the client can Open the xmlhttp. Open ("GET", url, false) asynchronization.
2. xmlhttp on the server. responsebody uses Responsebody instead of ResponseText or ResponseXml. at the beginning, I use ResponseText, but an error is prompted when the bytesToBSTR function is used for encoding conversion, after comparison, the code in other asp thieves were found to be Responsebody. after analysis, the invention body returned binary data instead of returning characters or dom objects like ResponseText or ResponseXml.
Asp proxy functions of ajax:
Send_request (url). The url is the address.
The server code is as follows: take the initiative to determine all character encoding. the Japanese and Korean traditional Chinese have been tested:
Reference content is as follows:
<% @ LANGUAGE = "JAVASCRIPT" CODEPAGE = "65001" %>
Http://www.w3.org/TR/html4/loose.dtd>
XMLHTTP
<%
Server. ScriptTimeout = 9999999;
Function send_request (url ){
Var codedtext;
Http_request = Server. CreateObject ("Microsoft. XMLHTTP ");
Http_request.Open ("GET", url, false );
Http_request.Send (null );
If (http_request.ReadyState = 4 ){
// Actively determine the start of encoding
Var charresult = http_request.ResponseText.match (/CharSet = (\ S) \ ">/I );
If (charresult! = Null ){
Var Cset = charresult [1];
} Else {Cset = "gb2312"} // gb2312 Code is used for websites that cannot be obtained. you can change the code on your own.
// Actively determine the end of the encoding
Codedtext = bytesToBSTR (http_request.Responsebody, Cset );
} Else {
Codedtext = "Erro ";
}
Return (codedtext );
}
Function bytesToBSTR (body, Cset ){
Var objstream;
Objstream = Server. 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;
Return (bytesToBSTR );
}
%>
<% Response. Write (send_request ("http://www.daum.net") %>