DQC online service with json

(ananda krishna) #1

Online service is created json ouput. But I not am able to use the online service output in JQuery Ajax call.

It would great if you have any example to use online service in ajax call.


Hello Ananda.
You mean it is not working? (You are saying “I am able”, should that be “I am not able”?)

In any case, what kind of error are you seeing? What kind of client are you using to execute the script?

(ananda krishna) #3

Sorry for Typo in the question.

I am getting following error when I try to access the online service from JQuery ajax call.

XMLHttpRequest cannot load http://localhost:8888/DQConlineService. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:49839’ is therefore not allowed access. The response had HTTP status code 500.

I am using Chrome browser to test it.


Hello Ananda,

What you are experiencing is basic browser security feature called “same origin policy”. This is present in all the browsers and will not allow any cross-domain requests to be processed. So for example if your web page is running inside the “server1” and your api endpoint is in “server2”, then request from your web-page will not be able to reach and call data from endpoint running anywhere outside of the server the page is running on. Please note that in this case server is instance, it does not matter that they both run on localhost, from the standpoint of the same origin policy, they are in fact two different servers.
This is general security policy that is set up for all available browser, it is nothing Ataccama related.
NOTE: if you are to call this json endpoint from outside the browser (i.e. server call, or js call from Node), your request will be succesfull. Same origin policy is tied specifically to web browsers.

Now to get this working, you can use CORS requests (Cross Origin Resource Sharing). This is in fact working for Ataccama web services but the client must send CORS request instead of the simple XMLHttp request that jQuery is sending.
Here is simple intro to get it working:

I don’t know how to get it working for jQuery requests, but if you use javascript xhr request, then (considering you have up to date browser) request should work. Something like this works with our services:

var xhr = new XMLHttpRequest();
xhr.open(“POST”, “http://localhost:8888/component”);
“in”: {
“columns”: {“src_name”: “”}

(ananda krishna) #5

This answer helped me. Thank you Marek.