0
我在爲我的數據訪問的js文件下面的代碼:
GroupsApp.factory('availableQuestionRepository', function ($http, $q) {
var factory = {};
factory.get = function (groupID) {
var deferred = $q.defer();
var url = "questiongrouping/AvailableQuestions/";
url = url.concat(groupID)
$http.get(url).success(deferred.resolve).error(deferred.reject);
return deferred.promise;
}
factory.save = function (availableQuestions) {
var deferred = $q.defer();
$http.post("questiongrouping/PostQuestions", availableQuestions)
.success(function() { deferred.resolve(); })
.error(function() { deferred.reject(); });
return deferred.promise;
};
return factory;
})
而且控制器,如下所示:
GroupsApp.controller("availableQuestions", function ($scope, availableQuestionRepository, msgBus) {
$scope.$on('GroupChanged', function() {
loadAvailableQuestions();
});
$scope.save = function (aq) {
availableQuestionRepository.save(aq).then(
function() { alert("sucess") },
function() { alert("error") });
}
function loadAvailableQuestions() {
availableQuestionRepository.get(msgBus.groupID).then(function (AvailableQuestions) { $scope.availableQuestions = AvailableQuestions });
}
});
的MVC控制器代碼如下:
Function PostQuestions(result As List(Of QuestionRO)) As ActionResult
Return New HttpStatusCodeResult(System.Net.HttpStatusCode.OK)
End Function
爲什麼當我用chrome瀏覽頁面時總會彈出錯誤提示?我已經在IE 10中試過了,它會彈出成功提醒框。
Chrome調試工具顯示什麼錯誤? –
不幸的是我在chrome調試工具中看不到任何錯誤。我應該在哪裏尋找錯誤? – Chris
你應該在網絡標籤上看到一個關於questionGroup/PostQuestions的問題 –