title: SAP Hana XSJS Ajax Post - Internal Server Error
body: <p>I have 2 component in my XS engine.</p>
  
  <ol>
  <li>Html file</li>
  <li>XSJS file</li>
  </ol>
  
  <p>I call below code to get some information from database.</p>
  
  <pre><code>$.ajax({
    url: "file.xsjs?ACTION=GET_BUBBLE_CHART_DATA",
    type: "POST",
    data: JSON.stringify({ d1: "xyxyxyx" }),
    contentType: 'application/json; charset=utf-8',
    success: function(datum) {
      if (datum != "") {
        console.log(datum);
      } else {
        alert("Please Try Again");
      }
    },
    error: function(jqXHR, textStatus, errorThrown) {
      console.log(errorThrown);
    }
  });
  </code></pre>
  
  <p>XSJS file is like below</p>
  
  <pre><code>var METHOD = $.request.method;
  
  switch (METHOD) {
    case $.net.http.GET:
      GET();
      break;
  
    case $.net.http.POST:
      POST();
      break;
  }
  
  function POST() {
    var d = JSON.parse($.request.body.asString());
    var action = $.request.parameters.get("action");
    $.response.setBody(JSON.stringify(d));
    try {
      var response = null;
      switch (action) {
        case 'GET_BUBBLE_CHART_DATA':
          response = d;
          break;
        default:
        // Don't do anything
      }
      $.response.setBody(response);
      $.response.status = $.net.http.OK;
    } catch (e) {
      $.response.contentType = "text/plain";
      $.response.status = $.net.http.INTERNAL_SERVER_ERROR;
      $.response.setBody(JSON.stringify(e));
    }
  }
  </code></pre>
  
  <p>I already searched stackoverflow and saw web.config file settings but this is not an .NET web application and <a href="https://stackoverflow.com/questions/22038177/jquery-ajax-post-internal-server-500-error">Jquery Ajax Post - internal server 500 error</a> didn't help.</p>
  
  <p>If you have any idea I would appreciate. </p>