且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

$ http.post要求不angularJS工作吗?

更新时间:2022-06-24 06:41:45

的2柱间的主要区别在于,在第​​一发回一个对象具有两个字段(名称和SectionTypeId),而第二只发送回的内容$ scope.message。 我可能是错的,但它看起来像$ scope.message是一个字符串。但是,您的内容类型设置为应用程序/ JSON。

The main difference between your 2 posts is that the first sends back an object with two fields (Name and SectionTypeId), while the second only sends back the contents of $scope.message. I could be wrong, but it looks like $scope.message is a string. However, you are setting the content-type to application/json.

这两者之间的区别是第一篇文章发送此的对象的:

The difference between the two is the first post sends this object:

{
    SectionTypeId: 0,
    Name: [
        {"name"="abc", "id"="1"},
        {"name"="bcd", "id"="2"}
    ]
}

而第二个职位发送此的阵列的:

[
    {"name"="abc", "id"="1"},
    {"name"="bcd", "id"="2"}
]

您需要或者重组你的code使得$ scope.message是你的服务器接受或喜欢你的第一个例子中的对象包装$ scope.message有效的JSON对象。

You need to either restructure your code so that $scope.message is a valid json object that your server accepts or wrap $scope.message in an object like your first example.