Skip to Content

CORS issue with UI5- XSJS application

Hi All,

I am trying to make an application which can send data from UI5 application to HANA Xs service with complete URL.

With my use case , i can't specify destination.

Even after enabling cors settings i cant bypass the cors issue in chrome or any other web browser.

MY code is :

	var url = "https://XXXXXXXXXXXX.hana.ondemand.com/TESTUSER/recieveData.xsjs";
	var that = this;
	//myEventList = some json data
	var username = "userName";
	var password = "password";
	if (myEventList.length > 0) {
		$.ajax({
			type: "POST",
			url: url,
			dataType: 'json',
			async: false,
			beforeSend: function(xhr) {
				xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
			},
			data: JSON.stringify(myEventList),
			success: function(result) {
				myEventList = [];
			},
			error: function(response) {
				console.log(response);
			}
		});
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 01, 2017 at 07:46 PM

    I went through few documentation and with some attempts found the solution for cors

    You can find it in this blog How to fix cors

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 21, 2017 at 07:14 PM

    Have you try with JSonP ?

    Add comment
    10|10000 characters needed characters exceeded

    • i tried but , there is no more cors error but the data is also not getting passed.

      Can you suggest proper syntax for the call :) . My code is as following.

      var url = "https://XXXXXXXXXXXX.hana.ondemand.com/TESTUSER/recieveData.xsjs";
      	var that = this;
      	//myEventList = some json data
      	var username = "userName";
      	var password = "password";
      	if (myEventList.length > 0) {
      		$.ajax({
      			type: "POST",
      			url: url,
      			dataType: 'json',
      			async: false,
      			beforeSend: function(xhr) {
      				xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
      			},
      			data: JSON.stringify(myEventList),
      			success: function(result) {
      				myEventList = [];
      			},
      			error: function(response) {
      				console.log(response);
      			}
      		});