tags:

views:

59

answers:

1

I'm trying to do an ajax (restful service) call using $.get. It works perfectly in IE but gives '401 unauthorized' in case of firefox.

At first I thought it was 'NTLM authentication' issue and tried adding the domain( of restful service - eg: http://mydomain.com in about:config -> network.automatic-ntlm-auth.trusted-uris ) but no success.

I'm sure it's not the ntlm issue, as entering the same url (restful service) in the firefox browser is giving me the data, but gives 401 unauthorized through $.get.

Does anyone have any idea what could be the issue here.

Thanks

Update:

I just figure out, it was due to 'cross domain' issue as sAc mentioned. I've one more doubt w.r.t JSONP, the service which I'm using doesn't support additional parameters in the url. but if i've to use JSONP callback, i've to add "callback=?" to the url. Is there any way I can achieve this.

+1  A: 

From your comment:

if my server is on abc.xyz.domain.com, i'm trying to access data from efg.xyz.domain.com. I also tried this off the server, but same error

The abc.xyz.domain.com and efg.xyz.domain.com are different domains:

Take a look at Same Origin Policy

In computing, the same origin policy is an important security concept for a number of browser-side programming languages, such as JavaScript. The policy permits scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.

You may want to have a look at JSONP to get around it.

Sarfraz
Thanks sAc, I'll go through JSONP and see if using that fixes the problem.
comeonman