views:

277

answers:

5

I need to make an ajax request, IE Works OK, Firefox URI DENIED.

I googled and I found the the only way is to use JSON to eliminate and restrictions.

Is there some one got any example?

Thanks

+1  A: 

With jQuery it could look like this:

$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?" +
          "tags=cat&tagmode=any&format=json&jsoncallback=?",
    function(data){
      $.each(data.items, function(i,item){
        $("<img/>").attr("src", item.media.m).appendTo("#images");
        if ( i == 3 ) return false;
      });
    });
Koistya Navin
Are you sure this would work? Because I believe it won't due to same origin policy restrictions.
Ionuț G. Stan
it will work because this is a jsonp request, and you know this because you see the ? in the url. see jquery's jsonp documentation for more info.
mkoryak
@mkoryak, thanks. I got it.
Ionuț G. Stan
A: 

Alternatively, you can make your XMLHttpRequest specify your user-agent as IE (browser sniffing is stupid):

var req = new XMLHttpRequest();
req.setRequestHeader('User-Agent','MSIE 7.0');
req.open("GET", sURL, true);
req.onreadystatechange=function() {
    if (req.readyState==4) {
        alert(req.responseText);
    }
}
req.send(null);

Or better yet, send a strongly worded e-mail to the site admin about their not accepting requests from non-IE browsers. In this day and age, building an IE-only site is unacceptable. It undermines the accessibility & usefulness of the web in so many ways.

Calvin
A: 

Before you get in too deep, try using an absolute url in the request. The only difference I know of between IE and FIrefox that would apply here is that IE converts relative urls to absolute in http traffic.

kennebec
A: 

You can always use a serverside proxy.

epascarello
A: 

If this is a cross-site issue (I don't think it is), try setting up a subdomain for your site (say, flickrapi.acme.com) that is a CNAME to api.flickr.com.

richardtallent