0
我有以下服务定义
app.factory('savedPropertiesService', ['$http', function ($http) {
var sessionId = $('input[name=SessionGuid]').val();
var contactId = $('input[name=ContactId]').val();
var savedPropertiesService = {};
savedPropertiesService.getSavedProperties = function() {
return $http.get("/Contact/SavedProperties?sessionGuid="+sessionId+"&contactId=" + contactId);
};
savedPropertiesService.refreshSavedProperties = function() {
return $http.get('/Contact/RefreshSavedProperties?sessionGuid=' + sessionId + '&contactId=' + contactId);
};
savedPropertiesService.deleteSavedProperty = function (listingKey) {
return $http['delete']('/Contact/DeleteSavedProperty?sessionGuid=' + sessionId + '&contactId=' + contactId + '&id=' + listingKey);
};
savedPropertiesService.updateSavedProperty = function (prop) {
return $http.put('/Contact/UpdateSavedProperty/', prop);
};
return savedPropertiesService;
}]);
,它是在我的控制器使用像这样
$scope.$watch('items', function (newVal, oldVal) {
if (_.isEmpty(newVal) || _.isEmpty(oldVal)) return;
var prop = difference(newVal, oldVal);
savedPropertiesService.updateSavedProperty(prop)
.success(function (data) {
$scope.status = data;
})
.error(function (error) {
$scope.status = 'Unable to update saved properties data: ' + error.message;
});
}, true);
和服务端点(请不要判断VB)
<HttpPut()>
Function UpdateSavedProperty(rating As RatingDto) As JsonResult
Return Json(ControlLibrary.CS.__PropDetails.ContactPropertiesDataFactory.UpdateSavedProperty(rating), JsonRequestBehavior.DenyGet)
End Function
不管我做什么,永远达不到JSON.stringify或不是我的MVC3 enpoint并且框架引发异常。 System.ArgumentException:无效的JSON基元。
我甚至只是试图发布一个手工制作的对象,看它是否会让它到达终端,全都无济于事。
有没有人有什么建议可能是错误的代码?
谢谢 斯蒂芬