How to access RESTful services from an external server on my server in angularjs

I am running domain 1 server.

I have RESTful services on server2.

I want to access this RESTful service on my webpage using angularjs. I tried this way. But it returns an empty array. There was no data. What for? any suggestions. Here is my sample code.

0
angularjs resources angular-resource
May 09 '13 at 13:53
source share
2 answers

In your code example, the definition of your resource is as follows:

var UtilService = $resource('server2/users/:userId', { }, { 'get' : { method: 'GET',headers: {'Content-Type':'application/json'}, params: { userId:'anil' } , isArray : true } } ) 

This url looks relative. If you are trying to target a remote server, you will need a resolvable URI. If something that distorted the anonymity of your example, I think your problem.

0
May 09 '13 at
source share

I have the same problem as it seems to me. This is similar to the problem of SOP (same origin policy). You cannot access another port on the local host without using JSONP or CORS. (I have a question how to do this using CORS at the moment, but there are a lot of documents available in JSONP online). see also this question

Hope this helps.

0
May 15 '13 at 10:58
source share



All Articles