如何访问外部服务器上的RESTful服务在我angularjs服务器 [英] How to access the RESTful services from external server in my server in angularjs
问题描述
我在域服务器1上运行。
I am running on domain server1.
我有我的RESTful服务Server2上。
I have my RESTful services on server2.
我要使用angularjs我的网页访问此RESTful服务。我想这种方式。但是,它返回一个空数组。没有数据绑定。为什么?有什么建议么。下面是我的示例code。
I want to access this RESTful service on my webpage using angularjs. I tried this way. But it's returning an empty array. No data was bind. Why? any suggestions. Here is my sample code.
推荐答案
您遇到我类似的问题,我认为。它看起来像一个SOP(同源策略)的问题。不使用JSONP或CORS您不能访问本地主机上的不同端口。 (我有一个问题,与如何在瞬间做到这一点使用CORS打开,但有大量的文档可在网为JSONP)。 又见
You're having a similar problem to me I think. It looks like a SOP (same origin policy) issue. You can't access a different port on the local host without using JSONP or CORS. (I've got a question open with how to do this using CORS at the moment but there are plenty of docs available on the net for JSONP). see also this question
希望这有助于。
这篇关于如何访问外部服务器上的RESTful服务在我angularjs服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!