Skip to Content
avatar image
Former Member

Posting data to xsjs not working

Hello all

I am trying to send a data load from UI (SAPUI5) to the backend (xsjs).

Actually trying to use this example: Transferring complex structured data from UI to XSJS - POSTing JSON

But its not working!

Here my code:

new sap.m.Button('databutton',{
     text: "send data!", 
     press:function(){
          $.post( "/services/test.xsjs", 
                            { JSON_DATA: {"Name": "Test"} } 
          )
          .done(function(data){
               alert(data);
           });
      }
 });

I can see the button but when I click it, nothing happens!

The backend looks like this:

var JSONString = $.request.parameters.get("JSON_DATA");
var JSONObj = JSON.parse(JSONString);
$.response.status = $.net.http.OK;
$.response.setBody(JSONObj.Name);

Where is the problem?

Greetings, Jan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Sep 12, 2015 at 02:31 PM

    Did you check the network tab in your browser to find if the request is triggered to the backend ? If yes, can you check what is the response that you get from the request ? Also, have you enabled xcsrf token in your xs app ? If yes, are you passing the token along with the POST request ?

    Add comment
    10|10000 characters needed characters exceeded