Skip to Content
author's profile photo Former Member
Former Member

AJAX request over SAP Gateway (ajax same origin policy)

Hi,

I am running a SAPUI5 Webapp on our Server. How it is possible to route a ajax request over the SAP Gateway (or something else).

JSONP is no option.

The request is like

var url = "http://maps.googleapis.com/maps/api/geocode/json?address=" + sTerm + "&sensor=false"

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Nov 13, 2015 at 11:00 AM

    Please check this example. its should be useful Simple cross-domain Ajax request


    Kindly let me know if you need any more information.

    Add a comment
    10|10000 characters needed characters exceeded

    • I used this code in my application. this code don't have "JSONP". is it useful

      var sServiceUrl = "http://hostName:portNumber/demo.sap.com~b2b~rest~web/rest/ptngrp/search";

      var oModel = new sap.ui.model.json.JSONModel();

      var ptnergrpdetails;

      function getPartnerGroupDetails(datak)

      {

      $.ajax({

      processData: false,

      url : sServiceUrl,

      type : "POST",

      contentType : "application/json; charset=utf-8",

      data :JSON.stringify(datak),

      dataType: 'json',

      //async : true,

      //username : cUserName,

      //password : cPassword,

      success : function(data, textStatus, jqXHR) {

      ptnergrpdetails = data;

      oModel.setData({ptnergrpdetails:data})

      //console.log("json data "+oModel.getJSON());

      sap.ui.getCore().setModel(oModel,"oModel")

      },

      error : function(xhr, status) {

      //alert(datak)

      },

      complete : function(xhr, status) {

      }

      });

      }

      or

      $.ajax({
      url: "http://hostName:portNumber/demo.sap.com~b2b~rest~web/rest/ptngrp/search",
      data: cred,
      type: "POST",
      xhrFields: {
      withCredentials: true
      },
      success: function(response){
      alert('succeeded!');
      console.log(response);
      alert(response);
      },
      failure: function(message){
      alert("failed");
      console.log(message);
      alert(message);
      }
      });
  • Posted on Nov 13, 2015 at 11:28 AM

    Hi Maximilian,

    You can use ODATA model to call server. It is an advanced version of ajax call.

    JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel

    Refer this: https://scn.sap.com/thread/3406353

    Regards,

    KA

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.