Answer the question
In order to leave comments, you need to log in
Why does the server return an error 500 when submitting a form using $http.post?
Submitting a form using AngularJS:
var app = angular.module('reg_app', []);
app.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}]);
app.controller('RegFormController', ['$scope', '$http', function($scope, $http) {
$scope.submit = function() {
var in_data = {user: $scope.user};
console.log(in_data);
$http.post('/reg/', in_data)
.success(function(data, status, headers, config) {
successCallback(data);
})
.error(function(data, status, headers, config) {
console.log('NOT OK')
});
};
}]);
in_data = json.loads(request.body)
print(in_data)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question