views:

29

answers:

2

Hi,

My question is specific to oodle API.

I am trying to call oodle API to get the JSON result like this:

$.getJSON("http://api.oodle.com/api/v2/listings?key=TEST&region=sf&category=sale&format=json&mappable=address&jsoncallback=none", function (data) {
    alert(data);
}
+1  A: 
$.getJSON("http://api.oodle.com/api/v2/listings?key=TEST&region=sf&category=sale&format=json&mappable=address&jsoncallback=?", function (data) {
    alert(data);
});

This uses JSONP. The ? tells jQuery where to insert the name of the callback. You had none, which is incorrect. Also, you were missing a right paren.

Matthew Flaschen
Thanks for the answer. But in oodle api they told that you can give either your name or none. I have given none.Sorry to ask but which right parenthesis I forgot.
You can't use none because of the cross-domain restrictions; you need to use JSONP. The paren was the one closing the method.
Matthew Flaschen
+1  A: 

You cannot make cross domain request (XSS). You will need to use JSONP by changing the jsoncallback parameter from your request to jsoncallback=? instead of none. The latest version of jquery will then handle JSONP correctly.

The Oodle API specs mentions jsoncallback: http://developer.oodle.com/listings

Adam
Hi I am using jquery 1.4.2 and tried to do the same thing you told but in Firebug it's showing error.Don't know what to do?Here is that code.$(document).ready(function () { $.getJSON("http://api.oodle.com/api?key=TEST }); });I don't know why it's not working?
I tried it quiclky and FireBug showed a 500 response from the server. If you look at the response it's a blank page with the Oodle template. Seems to me that the request went through correctly, but Oodle had a problem with it. This could be because key=TEST, but I don't know. Maybe someone at Oodle can help you. Sorry.
Adam
Thanks for the efforts Adam. I was suspecting and it became truth because I was accessing from localhost it might not get response and when i deployed that test page on my host site it got..so may be because of domain trust. thanks a lot anyway.