Skip to Content
0

CORS issue with UI5- XSJS application

Sep 21, 2017 at 12:41 PM

100

avatar image

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);
			}
		});
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Gopal Anand
Oct 01, 2017 at 07:46 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Joseph BERTHE Sep 21, 2017 at 07:14 PM
0

Have you try with JSonP ?

Show 1 Share
10 |10000 characters needed characters left 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);
			}
		});
0