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).

    评论

报告相同问题?