Skip to Content
Nov 08, 2018 at 03:16 PM

How to insert data from SAP ui5 screen to database using XSJS service?


Hi All,

This may be a repetitive question, but I find it difficult to fetch data from UI screen using AJAX POST request. Below is the code snippet of the ajax request that is a part of the index.html file

url : 'https://ajrbt0xgat8bnan8-new-newjs.sg11scbh1ddd0.hec.xxxx:30033/test.xsjs',
type : 'POST',
contentType : 'application/json',
data : JSON.stringify(oEntry),
dataType : 'json',
success : function(data) {         
error : function(error) {     
alert("Error Inserting Data")

And below is the xsjs file that consumes the data

var data1 = $.request.body.asString();  
var d = JSON.parse(data1);
$.response.contentType = 'text/html';
$.response.headers.set("Access-Control-Allow-Origin", "*");
$.response.status = 200;  

Problem here is the xsjs service is not invoked as I get the alert "Error Inserting Data"

Please help and guide as I'm new to SAP HANA on whole.