on 09-21-2017 1:41 PM
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);
}
});
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you try with JSonP ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
}
});
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.