Link to home
Start Free TrialLog in
Avatar of roddios
roddios

asked on

Ajax call doesn't work in Firefox

Hello Experts
We have a webservice that was developed and tested in IE. After development we found out that it doesn't work in firefox. There is no error on the page but the drop down data that is returned via webservice call is empty.. we're using jqoery jquery-1.3.2.js is used for the webservice call...

I would appreciate if someone knows about any known bug or put my on the path to find the answer..
when I look at the firefox error console. it says:
uncaught exception: [Exception... "Access to restricted URI
denied"  code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"

Thanks
Rod
$.ajax({
                    type: "POST",
                    url: "http://..../TaxonomySearchService.svc/web/GetAssociation",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    data: '{ "SubjectSide_TargetID":"' + SubjectSide_TargetID + '", "...."'"}',
                    success: function(data, associationValues) {
 
 
                        activityOptions[index++] = new Option(heading, "");
                        
                        $.each(data.d, function(i, association) {
                            var value = association.TARGET_VOCAB_ID;
                            var text = association.TARGET;
 
                            var activityOption = new Option(text, value);
                            activityOptions[index++] = activityOption;
                        });
 
                        LoadData(dropdown, activityOptions);
                    },
                    error: function(msg) {
                        alert(msg);
                    }
                });

Open in new window

Avatar of Morcalavin
Morcalavin
Flag of United States of America image

Is the url on the same domain?

Sometimes referencing a link with the http:// or http://www prefixes may cause the cross-domain scripting security to fire.

If it's on the same domain, try using just an absolute path reference to the script:
url: "/TaxonomySearchService.svc/web/GetAssociation"
Avatar of roddios
roddios

ASKER

Thanks for your response. no the url is actually on a remote machine
You can't do ajax calls to a remote machine.  Ajax only works on the same domain.  In order to do ajax calls to another domain, you must call a proxy script on your domain that runs server side.  That proxy script contacts the remote domain and returns the information to your local domain.
Avatar of roddios

ASKER

I'm on VPN connected to the domain. What I meant was that the service is not running locally so I don't think I can omit the http from the url. My ajax call works in IE7  
If your javascript resides on http://www.mydomain.com and you want to access http://www.yourodmain.com, you cannot do that without a proxy script like I mentioned in the above post.  Browsers have a cross-domain policy that prevents the xmlhttprequest object from contacting other domains.  If it works in IE7 and there are two domains involved, that's a bug.
Avatar of roddios

ASKER

I have absolutely no idea what a javascript proxy is.. could you explain /  give examples
ASKER CERTIFIED SOLUTION
Avatar of Morcalavin
Morcalavin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of roddios

ASKER

thanks.. good stuff