Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('testSendData', [])
- .controller('sendDataCtrl', function($scope, $http, $window, $exceptionHandler){
- $scope.username = "";
- $scope.pass = "";
- $scope.sendData = function(){
- if($scope.username == "") {
- $window.alert("Username Field Is Empty");
- return;
- }
- else if($scope.pass == "") {
- $window.alert("Password Field Is Empty");
- return;
- }
- var data = {details: JSON.stringify({
- username: $scope.username,
- password : $scope.pass
- })
- };
- console.log("Data That Going To Be Sent as json: ");
- console.log(data);
- $http.post("server", data).
- success(function(data) {
- console.log("Sended Username: " + $scope.username + " pass: " + $scope.pass);
- }).error(function(data) {
- console.error("error in posting");
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement