O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting with AJAX

Now that we have the login page in place, we can actually connect to our backend, something we have not done yet! Basically, what we want is to log in and redirect to the shopping cart (which kind of serves as our personal page for this project). In the frontend, this is easy enough. We need to inject the $http module to our Angular controller that we can use to make an AJAX call. After that, we can call our backend and redirect on success or show an error when the user was not found:

$scope.login = function () {   $scope.notFound = false;   $http.post('/login', {      username: $scope.username,      password: $scope.password   }).then(function (response) {      if (response.data.success) { window.location.replace("/shopping-cart.html"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required