Visual Studio 2013

时间:2015-10-08 12:52:44

标签: asp.net

我得到了无效的JSON'我在visual studio 2013中运行以下代码时出现错误消息,但是如果我将相同的代码复制到visual studio 2010则可以正常工作。这是代码:

<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function drawChartttt() {
            var test = window.location.href + "/test";

            var name = "sss";

            $.ajax({
                type: "POST",
                url: window.location.href + "/test",
                data: "{'name':'tman'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (r) {
                    alert("success");
                },
                failure: function (r) {
                    alert("error 1");
                    alert(r.d);
                },
                error: function (xhr, status, error) {
                    // alert("error 2");
                    alert(error);
                    alert(xhr);
                    alert(status);
                }
            });
        }


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

        });

    </script>

服务器端:

  [WebMethod]
     public static string test(string name)
      {
          return "tman";
      }

alert(status)显示parsererror

可能是什么问题?

0 个答案:

没有答案