json_2.0.4 for ASP使用方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.Charset = "UTF-8"
Response.ContentType = "text/JSON"
%>
<!--#include file="Inc/Json_2.0.4.asp"-->
<%
Dim Jsons
Set Jsons = jsObject()
Jsons("Name") = "张三"
Jsons("Age") = 30
Jsons.Flush '输出结果:{"Name":"张三","Age":"30"}
'复杂对象及数组你应该查看json_2.0.4的帮助文档了
Set Jsons = Nothing
%>

以下是前台jQuery请求:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$.ajax({
type:"GET",
url:"AJAX.asp",
data:"a="+ Math.random(),
cache:false,
datatype:"JSON",
error:function(x,y,z){alert("读取数据错误:" + y);},
success:function(data){
var jsonErr = false;
try{var json = $.parseJSON(data);}catch(e){
alert("返回数据错误:" + e.message);
jsonErr = true;
}
if(!jsonErr){
alert("名称:"+json.Name);
alert("年龄:"+json.Name);
}
}
});

未经允许不得转载:王超博客 » json_2.0.4 for ASP使用方法

赞 (1)

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址