on 10-26-2017 10:02 PM
Hi All,
I was trying to set the text of the Button to currently logged in username with jQuery.ajax call. But couldn't figure out the problem here. Please help.
view.xml
<Button id="idUserBtn" icon="sap-icon://customer" tooltip="User Information" type="Transparent"/>
controller.js
var oUsername = this.getView().byId("idUserBtn");
jQuery.ajax({
url: "https://..../services/serverLogic.xsjs",
method: 'GET',
dataType: 'json',
success: function(username) {
oUsername.setText(username);
},
error: function() {
oUsername.setText("fail");
}
});
serverLogic.xsjs
function getUsername() {
var username = $.session.getUsername();
return username;
}
var result = getUsername();
$.response.setBody(result);
Hi,
The AJAX call to the back-end is async by default. Looks like your success handler is reached only after the screen is rendered. You can try by re-rendering your button after setting its text in the success handler.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
your ui5 app in hana? or in another place...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.