JQuery post JSON数据抛出错误,"未引号标识符'Id'在位置0"

JQuery post JSON data throwing error, "unquoted Identifier 'Id' at position 0"

本文关键字:quot post 标识符 Id 位置 错误 出错 数据 JSON JQuery      更新时间:2023-09-26

使用Fiddler来监视Jquery帖子,我在Fiddler中得到一个错误。

未加引号的标识符'Id'位于位置0

我错过了什么?

  var UserModel =
            {
                Id: "12345",
                Name: "MyName"
            };             
            $.ajax({
                type: "POST",
                url: '@Url.Action("MyAction")',
                data: UserModel,
                datatype: 'json',
                contentType: "application/json",
                success: function (response) {
                    alert("Success");
                }
            });

你忘了加引号

var UserModel =
            {
                "Id": "12345",
                "Name": "MyName"
            };