Skip to main content
edited tags
Link
Kevin Montrose
  • 18.7k
  • 6
  • 35
  • 62
edited tags
Link
Jason
  • 3.1k
  • 19
  • 11
Source Link
Jason
  • 3.1k
  • 19
  • 11

I can't get a response for /questions/{id} in Chrome Extension

I'm writing a Chrome Extension that queries the API. Using jQuery, I have the following code called from my background page:

$.ajax({
    url: 'http://api.stackoverflow.com/0.8/questions/' + id
    , success: function(data, status, xhr) { console.log(data,status,xhr); }
    , dataType: 'json'
});

but I keep getting null for data, even though the call is successful (I have tried substituting id for a hard-coded, existing question id, so it's not the id). Using Chrome's (underpowered) console debugger, I discovered these request headers:

Accept:application/json, text/javascript, */*
Origin:chrome-extension://ogaegmflccigoelneakdpgbkccoakcbg
User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.4 
(KHTML, like Gecko) Chrome/5.0.375.55 Safari/533.4

What am I doing wrong? If I can't make API calls from a Chrome Extension, then I've just wasted a few days of side-project programming time, which would suck...