weixin_33698823 2017-01-09 12:44 采纳率: 0%
浏览 27

查看AJAX返回的JSON

Please see the code below:

<script type="text/javascript"  src="Javascript/json2.js"></script>
    <script type="text/javascript" src="Javascript/jquery-1.11.1.min.js"></script>
    <script type = "text/javascript">
        function GetData() {
            $.ajax({
                type: "POST",
                url: "JSONExample.aspx/GetPerson",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess(),
            //async: false,
            failure: function (response) {
                alert('there was an error counting possibles')
            }
        });

        function OnSuccess() {
            return function (response) {
                alert(response.d);
            }
        }
        }
        GetData()
    </script>

I believe response.d returns the desterilized JSON. How do I see the JSON so that I can desterilize it myself into a .NET Object?

  • 写回答

2条回答 默认 最新

  • local-host 2017-01-09 13:01
    关注

    Try with this:

    <script type="text/javascript"  src="Javascript/json2.js"></script>
        <script type="text/javascript" src="Javascript/jquery-1.11.1.min.js"></script>
        <script type = "text/javascript">
            function GetData() {
                $.ajax({
                    type: "POST",
                    url: "JSONExample.aspx/GetPerson",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                //async: false,
                failure: function (response) {
                    alert('there was an error counting possibles')
                }
            });
    
            function OnSuccess(data) {
                alert(data);
            }
            GetData()
        </script>
    

    Also, you can debug information with the developper tools of your Internet browser (F12 by default).

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿