我需要将请求负载中的数组传递给BACKBONE中的POST API调用。我尝试在save()中传递数组,但它不会像预期的那样。我从服务器得到的响应是“错误的请求,期望一个数组”。 阵列预计要为: [ “A”, “B”] 0: “一” 1: “b” 的 我的代码它将会为: {0: “一”,1: “b”} 0: “一” 1: “b” 的 这里是js代码我尝试:使用backbone.js .save()方法在请求有效负载中传递数组请求负载
var PolicyGroupMembers = Backbone.Model.extend({
id1:"",
url: function(){
var url1= "http://localhostIP:9292/api/policy_groups/" +this.id1 +"/members";
return url1;
},
// Before calling the save() function configure request
configRequest:function(options) {
this.id1 = options.id1;
});
var systemGroup5 = new PolicyGroupMembers();
systemGroup5.configRequest({
id1: "Ppj--v4UT1-NwrZ7PQkgOg"
});
systemGroup5.save(["a","b"]);
您的建议高度赞赏。
类似的问题:http://stackoverflow.com/a/27051113/4116375 – knpsck 2014-11-25 10:05:57