Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3548

Sapui5 Login using ajax and json

$
0
0

I want to make view like if i success to login and view move to next view.

but i have problem about checking my user id and password using ajax and json data.

I think i have problem ajax part in cotroller.js

Please senior developer help this problem

here is my code

 

Login.view.xml

 

 

  <content>

 

 

  <form:SimpleForm maxContainerCols = "3" layout = "ResponsiveLayout">

  <form:content>

  <Label text = "" />

  <Input id = "username" type = "Text" placeholder = "Username" />

 

  <Label text = "" />

  <Input id = "password" type = "Password" placeholder = "Password" />

 

  <Label text = "" />

  <Button id = "login" press = "hello" text = "Login" />

  </form:content>

 

  </form:SimpleForm>

 

 

  </content>

 

 

Login.controller.js

 

hello: function(oEvent) {

 

  var user = this.byId("username").getValue();

  var passw = this.byId("password").getValue();

 

  $.ajax({

  type : "POST",

  url : "User/user.json",

  dataType : "json",

  async : false,

  data : '{"userName": "' + user + '", "password" : "' + passw + '"}',

  success: function (data) {

  if(user == value.user_name && passw == value.user_name) {

 

  var MP = new sap.ui.view({viewName:"test.Menu",type:sap.ui.core.mvc.ViewType.XML});

  var DP = new sap.ui.view({viewName:"test.Dashboard",type:sap.ui.core.mvc.ViewType.XML});

  var split_container = new sap.m.SplitContainer({

  masterPages: MP,

  detailPages: DP

  });

 

  app.addPage(split_container);

  app.to(split_container);

  }

 

 

  }

  });

 

 

user.json

 

{

"1" : {

"user_name" : "hello",

"password" : "1234"

},

 

 

"2" : {

"user_name" : "gwanghyun",

"password" : "1234"

}

}


Viewing all articles
Browse latest Browse all 3548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>