Let's say that I have data that has a complicated format (a list of object) that I want to post to an MVC controller, and then I want this controller to redirect me to the page i want with the model it generated. Just like a POST request from a regular form would do.
Instead, when I do this angular request with angular:
$http({
method: 'POST',
url: '/user/search',
data: $scope.dataToSearch
}).success(function() {
// what do put here ?
})
.error(function() {
});
All I receive is a status code 200, and the raw html of the page I wanted without redirecting me to this actual page. The thing is, if I do "window.location" on success, my controller won't generate the model because I have to post the data.
In conclusion, how to post then redirect like with a regular form, but with using Ajax/Angular/Javascript in general ? Thanks.
You may use the Angular promises
for return and wait the success request. So, you need more control from controllers, Restangular
is better for this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.