Question

I have the following code in a js file for my data access:

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;
})

And the controller is as follows below:

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 });

}
});

The MVC controller code is as follows:

Function PostQuestions(result As List(Of QuestionRO)) As ActionResult
    Return New HttpStatusCodeResult(System.Net.HttpStatusCode.OK)
End Function

Why is it when I go to the page in chrome it will always pop up the error alert? I have tried it in IE 10 and it will pop up the success alert box.

Pas de solution correcte

Autres conseils

I finally figured out what is causing my problem. The problem was including the tag:

<form class="form">

</form>

Once I deleted this tag the button for submitting data worked correctly.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top