2012. 2. 1. 11:27

Ajax cross domain (proxy 이용)

function getData(url) {
xmlHttp = getXMLHttpRequest();
var proxyUrl = escape(url);
var crossUrl = "proxy_xml.asp?argUrl="+proxyUrl+""; 
xmlHttp.onreadystatechange = function (){
if (xmlHttp.readyState == 4){
if(xmlHttp.status == 200 || xmlHttp.status == 304){
}
}
};
xmlHttp.open("GET", crossUrl, true);
xmlHttp.send(null);
}

----------------------------------------------------------------------
proxy_xml.asp

<%
Response.expires = -1
Response.AddHeader "Content-type", "text/xml"
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-control", "no-store"
Response.buffer = true
Response.ContentType="text/xml"
Response.CharSet = "UTF-8"

argUrl = Request.Querystring("argUrl")

Set data = Server.CreateObject("Scripting.Dictionary")

        Set objXmlHttp  = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
    
objXmlHttp.open "GET", argUrl , False

        '요청
        objXmlHttp.send

'응답 텍스트 저장
        strResponseText = objXmlHttp.responseText
Response.Write strResponseText
%>