htmlページ提出JSON,ASPページ受信印刷

4073 ワード

jsonSubmit.html
1)javascript関数駆動要求ページを通過できる



	 js json    asp       
	


	

に む

function queryStudent() { // body... var student = { name:" ", age:18, city:" " }; var myJSON = JSON.stringify(student);<br>          // json window.location="http://localhost:8078/test/jsonPrint.asp?student="+myJSON }

 2)jsonPrint.asp
JSONを受信して印刷した印刷子の項目を解析する


    dim student
    student=request("student") 
%>


    json <span style="color: #0000ff;">return</span>
    "utf-8">


'             
Dim scriptCtrl  
Function parseJSON(str)  
    If Not IsObject(scriptCtrl) Then  
        Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl")  
        scriptCtrl.Language = "JScript"  
        scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;"  
    End If  
    scriptCtrl.ExecuteStatement "result = " & str & ";"  
    Set parseJSON = scriptCtrl.CodeObject.result  
End Function  
%>

    set stuJSON=parseJSON(student)
    Response.Write("  json  :"+student+"
") response.Write("

:

"+stuJSON.name+"") response.Write("

:

"+stuJSON.name+"") response.Write("

:

"+stuJSON.name+"") set stuJSON=nothing %>