showing results for - "send json object to xsjs"
Viktoria
27 Jun 2017
1
2return new sap.ui.commons.layout.MatrixLayout({
3  id : "matrix1",
4  layoutFixed : false
5  }).createRow(oTable).
6  createRow(new sap.ui.commons.Button({
7  text : "Submit",
8  press : function(evt){
9  //Getting the JSON data bound to the table object (oTable)
10  var JSONData = oTable.getBinding().getModel().oData.modelData;
11  //Converting the JSON object to a string variable (formalluy serialization)
12  var JSONString = JSON.stringify(JSONData);
13  //Making an AJAX POST call
14  $.post("proxy/Finance/XSApps/test.xsjs",//this is the target URL
15  { JSON_DATA: JSONString } //Data passing with attribute naem JSON_DATA
16  ).done(function( data ) {//Success function call
17     alert( "Data returned rom XSJS: " + data );
18   });
19  }
Isabell
08 Jun 2019
1
2var JSONString = $.request.parameters.get("JSON_DATA");//Reading the input JSON string
3var JSONObj = JSON.parse(JSONString);//serializing the input string
4// Now we have the JSON object with us. Do what ever manipulation you want to do on it.
5//For the test case i am just returning the number of rows in the JSON object
6$.response.setBody(JSONObj.length);