日期:2014-05-16  浏览次数:20610 次

ajax 返回json问题 急啊 谁帮帮我 - Web 开发 / Ajax
HTML code
<input type="button" value="测试" onclick="getAjaxList()" />
<script language="javascript">
function getAjaxList() {
     $.get("Community_Dictionary.asp",null,function(json){alert("xxxxxxx")},"json");
}
</script>


这是客户端代码

VBScript code
<!--#include file="../json.inc"-->
<%

set json=new Aien_Json                
json.JsonType="object"                
json.addData "Community_ID","1"        
json.addData "Community","aa"
json.addData "Address","aa"
json.addData "Area_ID","15"
jsonstr = json.getJson(json)
Response.Write jsonstr
%>


服务器输出结果为

{Community_ID:"1",Community:"aa",Address:"aa",Area_ID:"15"}

但为什么 点测试按扭没反应

但把客户端代码 返回类型 从 "json" 改为 "text"却可以运行代码 

是哪里出错了

急啊 谁帮帮我

------解决方案--------------------
应该没有将{Community_ID:"1",Community:"aa",Address:"aa",Area_ID:"15"}编译成json

------解决方案--------------------
$.get("Community_Dictionary.asp",null,function(json){alert(json.Community)},"json");显示什么?

------解决方案--------------------
是不是Content-Type的问题??
你默认输出text/html
是不是要改成json的??
------解决方案--------------------
Aien_Json 是你自己写的吗
------解决方案--------------------
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?", function(data){
$.each(data.items, function(i,item){
$("<img/>").attr("src", item.media.m).appendTo("#images");
if ( i == 3 ) return false;
});
});

服务器端 直接是json 格式的字符串。ok
------解决方案--------------------
CSS code

但把客户端代码 返回类型 从 "json" 改为 "text"却可以运行代码  
改成text,然后eval();
$.get("Community_Dictionary.asp",null,function(json){alert("is object" + eval(json))},"json");

------解决方案--------------------
= =,,你有试过指定Content-Type吗??为什么不试下呢?