ClassicASP 비동기 호출 mxsml2.xmlhttp
페이지 정보
본문
비동기 호출
1. http://from.happyjung.com/form.html 에서 내용 입력
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>비동기호출</title>
</head>
<body>
<form name="hpwrite" action="from.asp" method="post">
<input type="text" name="fname" value="해피정닷컴" /><br />
<input type="text" name="email" value="메일@해피정닷컴" /><br />
<input type="text" name="tel" value="070-7600-3500" /><br />
<input type="submit" name="submit" value="전송" />
</form>
</body>
</html>
2. http://from.happyjung.com/from.asp 비동기 호출할 페이지에 코드 삽입
<%
function GetFileFrom(sURL, sSavepath)
on error resume next
dim oHTTP, oStream
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
set oHTTP = Server.CreateObject("Microsoft.XMLHTTP")
oHTTP.open "GET", sURL, False
oHTTP.send
set oStream = Server.Createobject("ADODB.Stream")
oStream.type = adTypeBinary
oStream.open
oStream.write oHTTP.responseBody
oStream.savetofile sSavepath, adSaveCreateOverWrite
set oStream = nothing
set oHTTP = nothing
if err.number <> 0 then
GetFileFrom = false
else
GetFileFrom = true
end if
end function
dim fname, email, tel
dim fname, email, tel
fname = Request.QueryString("fname")
email = Request.QueryString("email")
tel = Request.QueryString("tel")
set oXmlhttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
oXmlhttp.open "POST", "http://to.happyjung.com/to.asp", false
oXmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlhttp.send "fname=" + fname + "&email=" + email + "&tel=" + tel
sResponse = oXmlhttp.responseText
set oXmlhttp = nothing
%>
3. 전송받는 URL의 페이지( http://to.happyjung.com/to.asp )에서 확인
<%
response.write "fname = "& request("fname") &"<br />"
response.write "email = "& request("email") &"<br />"
response.write "tel = "& request("tel") &"<br />"
%>
response.write "fname = "& request("fname") &"<br />"
response.write "email = "& request("email") &"<br />"
response.write "tel = "& request("tel") &"<br />"
%>
댓글목록
등록된 댓글이 없습니다.