Please use the following format when requesting data from an OData source:
oModel.read(
"/path",
{
success: function(oData, response) {
this.getView().byId("Categoryname").setText(response.data.CategoryName);
}.bind(this),
error: function(oError) {
this.getView().byId("txt").setText("test");
}.bind(this)
});
Important parts are marked with bold:
- use an object as second parameter.
- Bind the 'this' object to the function, which will provide you access to the controller inside the method.
However, it would be better if you use data binding to access data from your XML view.
Regards,
Istvan