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

关于服务器端返回json数据问题 - Web 开发 / Ajax
JScript code
function getAjaxList(explorer, pageno) {
    $
            .post(
                    "Community_Dictionary.asp",
                    null,
                    function(json) {
                        var jsonLength = json.list.length;
                        var dictionaryData = "";
                        if (jsonLength > 0) {
                            dictionaryData = "<div style='margin-bottom:10px;background-color:#d6efac;line-height:28px;padding-left:20px;'><img src='/house/img/xz_tb.gif'/><font color=green><b>选择小区</b></font>(如下列表中不存在,点此<a id='create-new-floor' href='javascript:void(0)'><font color=red>+新建小区</font></a>)</div>";
                            for ( var i = 0; i < json.list.length; i++) {
                                var Community_ID = json.list[i].Community_ID;
                                var Community = json.list[i].Community;
                                var Address = json.list[i].Address;
                                if (Address == "null")
                                    Address = "";
                                var Area_ID = json.list[i].Area_ID;
                                dictionaryData = dictionaryData
                                        + "<div style='height:22px;line-height:29px;padding-left:40px;overflow:hidden;'><img src='/house/img/sjy_x.gif'/><a  class='item' href=\"javascript:;\" onClick=\"javascript:selectFloor("
                                        + "'" + Community_ID + "'," + "'" + Community
                                        + "','" + Address + "','" + Area_ID + "');\"><font color=#ff6200>"
                                        + Community + "</font></a><font color=#565e53> " + Address
                                        + "</font></div>";
                            }
                            //dictionaryData += "<a id='create-new-floor' href='javascript:void(0)'>列表中不存在,<span style='color:red;font-size:16px;'>点此</span>新建小区</a>";
                        } else {
                            dictionaryData += "<a id='create-new-floor' href='javascript:void(0)'>列表中不存在,<span style='color:red;font-size:16px;'>点此</span>新建小区</a>";
                        }
                        $("#dictionary").html(dictionaryData);
                        $("#create-new-floor").click(onCreateNewFloor_Click);
                    }, "json");
}




这是客户端 js代码


Response.Write "{ ""list"": [{ ""Community_ID"": ""1"", ""Community"":""天才"", ""Address"": ""我晕晕"" ,""Area_ID"":""15""}]}"

这是服务器端代码

为什么客户端接收不到 服务器返回的结果

------解决方案--------------------
你先测试下
<form action="Community_Dictionary.asp" method=post><input type=submit></form>看看数据是否真的返回了
------解决方案--------------------
那就是你使用方法不对,或者你选择的框架解析有问题
------解决方案--------------------
可以得到的。

HTML code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
    getAjaxList(0,0)
    function getAjaxList(explorer, pageno) {
    $.post(