2

我有一个来自 REST Web 服务的 JSON 响应,并希望使用 jQuery 将该数据绑定到 html。看起来它甚至没有点击我在 jquery 中提供的 web 服务 url。Url 工作正常,它在浏览器中为我提供 JSON 数据,但我使用的 jQuery 无法从中获取任何内容。我在这里粘贴我的代码,请让我知道是否有人可以提供帮助。在调试脚本时,它直接在 ajax 调用中出现错误部分。

<script type="text/javascript">

 $(document).ready(function () {
        GetData();

    });

    function GetData() {

        //  alert(textblock.value);
        $.ajax({
            type: "GET",
            url: "http://localhost:8092/api/Employees",
            data: "{'employeeId'= '" + 1234 + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                var results = $.parseJSON(msg.d);
                alert(msg);
                alert(results);
            },
            error: function (result) {
                alert('here');
                var tt = result.text;
                alert(tt);
            }
        });
    }



</script>
4

1 回答 1

0

终于我现在可以获取数据了。我在 $.ajax 中添加了以下属性:

进程数据:假,异步:假,

于 2012-08-03T20:02:11.653 回答