Skip to Content
0
Apr 15, 2016 at 08:54 AM

Read body in XSJS

1658 Views

Dear Experts,

I post a request in fiori with following code:

addJob: function () {
  var oJsonData = {
  "JOBID":"JB9006",
  "DESCRIPTION":"AddJob9006",
  "DEPARTMENT":"AddDep.",
  "VALID_TILL":Date.now()
  };

  $.ajax({
  url:this.getView().getModel().sServiceUrl.substr(0,35)+"/update.xsjs?$mode=ins",
  type:'POST',
  contentType:'application/json',
  data: JSON.stringify(oJsonData),
  dataType:'json',
  success: function(){alert("Update Success!");}
  });
  }

But in update.xsjs, I can't read body with follow command:

var sData = $.request.body.asString();

It's always undefined.

How to read body of the request?

By the ways, develop environment of xsjs is HCP Trial.

Thanks & Regards.

Chad