2015-11-02 67 views
2

我有一个nodejs web服务url。通过我可以执行身份验证。我为此使用AJAX。我想用简单的javascript来做同样的操作。如何使用javascript从nodejs web服务获取数据?

这是我service.js代码

var LOGIN_AUTHENTICATION = "http://192.168.84.88:8888/AD-Service/rest/getEmpDetails/authenticateUser"; 

this.getLoginAuthentication = function(taskObject) { 
      var promise = null; 
      if (!promise) { 
       promise = $http({ 
       method: 'POST', 
       url: LOGIN_AUTHENTICATION, 
       data: taskObject, 
       headers: {'Content-Type': 'application/json'} 
       }).then(function(response) { 
        return response.data; 
       }); 
      } 
      return promise; 
     } 

这是我的控制器代码..

ProjectServices.getLoginAuthentication($scope.loginData).then(function(data) { 
    if(data=="true"){ 

    $state.go('app.calendar',{username:$scope.loginData.userName}); 

} 
else{ 
     $scope.myvalue = true; 
     $scope.loginData.password=''; 
     } 
    }); 

任何人可以帮我如何做到这一点简单的JavaScript ..?

回答

相关问题