Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

JSON model setData not working as expected

$
0
0

HI,

 

I'm a bit confused about the behaviour of the JSON model.

 

From what I understand from the AP documentationI, I would expect that

 

var xModel = new sap.ui.model.json.JSONModel("https://PATH_TO_REST_SERVICE");

var oParameters = {

    "Name": sap.ui.getCore().byId('txt_name').getValue(),

};

xModel.setData(oParameters);

sap.ui.getCore().setModel(xModel);

 

should do the same like

 

var xModel = new sap.ui.model.json.JSONModel();

var oParameters = {

    "Name": sap.ui.getCore().byId('txt_name').getValue(),

};

xModel.loadData("https://PATH_TO_REST_SERVICE", oParameters, true, "GET")

sap.ui.getCore().setModel(xModel);

which is sending the data in JSON format to the Server via GET.

 

But unfortunatelly, the first way does not work, the oParameters value is not being sent to the REST Service.

The second way works well.

 

What am I doing wrong?


Viewing all articles
Browse latest Browse all 6178

Trending Articles



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