0

I have created a sample application in Oracle JET which would route to the homepage upon login.

I want to validate the user credentials(username and password) with the table in the database using RESTful web services and only upon successful validation I want the application to be routed to the homepage.

Since I am new to Oracle JET and have less knowledge about integrating and validating user input with the data in the database, it would be a great if someone could help me with this. Thank you.

4

1 回答 1

0

您可以使用 ajax 方法来调用 restful web 服务。

这是一个可以帮助您的示例。

 self.username = ko.observable("");
 self.password = ko.observable("");
 self.login = function(data, event)
{
    $.ajax({
      url: "https://restservicesforlogin?username="+self.username()+"&userpwd="+self.password()+"",
      type: 'GET',
      headers: {
        your headers Details
                },

   success: function(data)
   {  


 if(self.ERROR_CODE()=='S')
 {

      oj.Router.rootInstance.go('homePage'); 
 }  
 if(self.ERROR_CODE()=='E')
 {
     alert("Invalid username/password");
     self.isLoggedIn(false);

 }  
        },
        error: function(jqXHR, exception)
        {
           alert("Internal Server Error") ; 
         }
   })
}
于 2017-05-08T11:13:52.683 回答