jQuery中JSONP

来源:互联网 发布:软件测试的含义 编辑:程序博客网 时间:2024/06/05 22:44

Html页面

<script type="text/javascript">
        $(function () {

            $.getJSON("GetData.ashx?rand=" + Math.random() + "&callback=?", function (data) {
                alert(data.Name);
            });


        });
    </script>

 

 

 

C#代码


        string callback = context.Request.QueryString["callback"];
        context.Response.Write(callback + "({\"Name\":\"CQHG\"})"); 

0 0