Hi afancy,

Webservers (e.g nginx, apache, spring and so on) basically do not allow
AJAX requests from other origin (host + ip).

(See https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)

If you want your webserver to respond requests from other origin, you
should set proper options in the webserver.

You can refer this site: http://enable-cors.org/index.html


Thanks :)

On Fri, Oct 28, 2016 at 4:14 PM, afancy <grou...@gmail.com> wrote:

> Hi all,
>
> I get json in the angular environment, but got the 
> 'Access-Control-Allow-Origin'
> exception. See the following.
> How to solve this issue? Thanks for your advice!
>
> /afancy
>
> %angular
> <script type="text/javascript">
>  readJson = function (url) {
>     $.getJSON(url, function(data){
>          console.log(data.body);
>     });
>  }
>
> readJson('http://129.241.107.186:4242/api/query/last?
> timeseries=ctt.traffic.JF&resolve=true');
> </script>
>
>
> XMLHttpRequest cannot load http://129.241.107.186:4242/
> api/query/last?timeseries=ctt.traffic.JF&resolve=true. No
> 'Access-Control-Allow-Origin' header is present on the requested resource.
> Origin 'http://localhost:8080' is therefore not allowed access.
>

Reply via email to