<%option explicit %> 를 asp 페이지에 상단에 추가함으로써 선언되지 않은 변수의 사용을 막는다.

코드가 길어지는 경우, 유지 보수에 도움이 된다. ( 변수가 의도와 다르게 사용되는 경우, 혼용 되는 경우를 막음 )

<% option explicit %>

Dim name
name="당꿈응"

Response.Write name

phone = "010-1234-5678" '선언되지 않은 변수사용으로 에러발생

Rs 에 계속 접근하기 보다는 배열에 복사에서 사용하는 것이 DB의 부담을 줄일 수 있다고 한다!!

 

Set Rs2 = Db.Execute(query2)

Dim arrRs '배열 선언

If Not Rs2.EOF Then arrRS = Rs2.GetRows()  '배열에 복사

Rs2.close

Set Rs2 = Nothing




If IsArray(arrRS) Then

  For i = LBound(arrRS, 2) To UBound(arrRS, 2)

    Response.Write arrRS(0, i)

    Response.Write arrRS(1, i)

 Next




Erase arrRS

End if

 

Option Explicit
 
Dim data, httpRequest, postResponse
 
data = "var1=somevalue"
data = data & "&var2=someothervalue"
data = data & "&var3=someothervalue"
 
Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpRequest.Open "POST", "http://www.example.com/handle.asp", False
httpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.Send data
 
postResponse = httpRequest.ResponseText
 
Response.Write postResponse ' or do something else with it

 

 

 

출처 : http://stackoverflow.com/questions/5300906/how-to-send-and-handle-http-post-in-asp

 

ASP JSON / ASP JSON 출력 / ASP JSON 생성


JSON과 XML을 사용하는데 있어서 서로 장단이 있지만, 많은 내용의 데이터를 전달해야 하는 경우라면

조금 더 속도면에서 유리한 JSON을 사용해 보는것도 좋다.


많은 양의 데이터를 다루는 경우라면 별도 함수를 생성해서 사용해야 겠지만, 

일단! 제대로 JSON이 출력되는지 아래와 같이 확인해볼 수 있다.





1
2
3
4
5
6
7
8
9
10
11
12
13
<%
response.write "{"
 
    response.write  """docType"":""new"""
    response.write  ",""rowNum"":""10"""
 
for i =0 to 10 step 1
 
    response.write  ",""tit"&i&""":""number "&i&""""
    response.write  ",""tit"&i&""":""number "&i&""""
 
next
response.write "}"
%>
 
cs




크롬에서 위 소스로 작성된 페이지를 실행시켜보면 아래와 같이 JSON형태로 출력되는 것을 확인 할 수 있다.





+ Recent posts