angularjs - Angular js and ionic -


how post html login form php login form in different url using angular js controller , returning success when login credential correct , failure when credentials wrong.below existing controller , intends use html login page while posts/authenticates login.php , returns success or failure upon input credentials

 .controller('loginctrl', function ($scope, $state, $ionicviewservice, $http, datastore) {     $scope.domain = datastore.domain;     var urlpath = datastore.domain+'/login.php';      $("#username").focus();     $("#username, #password").keyup(function () {         if ($(this).val().length !== 0) {             $("#validate").hide();         }     });      //authenticates blank fields     $("#login").on('click', function () {         if ($("#username").val() == '') {             $("#validate").html("username required").show();             $("#username").focus();          }         else if ($("#password").val() == '') {             $("#validate").html("password required").show();             $("#password").focus();         }          else {             $.ajax({                 type: "post",                 url: urlpath,                 data: $('#myloginform').serialize(),                 success: function (html) {                 var resp = html.split(":");                  // alert(resp[0]);                  if (resp[0] == 'success') {                      $("#validate").html("wrong username or password").show();                  }else {                       $state.go('menu.home');                     }                 }              });           // todo: login done here            //todo: validate login            $ionicviewservice.nextviewoptions({             disableback: true           });              //$state.go('menu.home');           return false;            };       }) }) 

have tried coding

else {     $http.post('http://localhost:0000', data).success(successcallback); } 

localhost ip or url of server wishing send post data to.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -