0

I think it's supposed to be on the response.code property, but I inspect the response object in firebug and I don't find the status response code anywhere. How do I know if the response is succesfull? Thanks.

gines capote
  • 1,110
  • 1
  • 8
  • 12
  • You need more detail if anyone is going to be able to help you. What API/endpoint are you using? What query are you sending? What response do you get? Are you talking about HTTP request status or a Freebase status? – Tom Morris Jun 06 '13 at 12:45

1 Answers1

1

In newer versions (1.5+) of jQuery you can use promises to handle success and error callbacks like this:

var API_KEY = 'YOUR-API-GOES-HERE';
var service_url = 'https://www.googleapis.com/freebase/v1/search';
var params = {
  'query': 'Blue Bottle',
  'key': API_KEY
};
$.getJSON(service_url + '?callback=?', params)
  .done(function(response) {
      $.each(response.result, function(i, result) {
        console.log(result);
      });
    })
  .fail(function() { console.log("error"); })
Shawn Simister
  • 4,613
  • 1
  • 26
  • 31