Assuming you have views/generic.jsonp
you need to enable it for remote requests:
def get_devices():
response.view = 'generic.jsonp'
devices = [r.hostname for r in db().select(db.device_status.hostname)]
return dict(devices=devices)
Then you need to call it with
jQuery.getJSON("http://.../get_devices.jsonp&callback=?", function(data) {
displayList(data);
}).error(function() { alert("error"); })
I did not try but should work.
On Wednesday, 12 October 2011 13:59:30 UTC-5, Harshad wrote:
>
> I know this has been discussed earlier, but I am not sure how to use
> JSONP for cross domain communication correctly. This is how I make the
> request:
>
> var jqxhr = $.getJSON('get_devices.jsonp', function(data) {
> displayList(data);
> })
> .error(function() { alert("error"); })
>
> I have tried the following URLs:
>
> 1. get_devices.json (works on local, fails on remote)
> 2. get_devices.jsonp (fails on local and remote)
> 3. get_devices.jsonp?callback=? (works on local, fails on remote)
>
> And my controller simply does the following:
>
> def get_devices():
> devices = []
> rows=db().select(db.device_status.hostname)
> for eachrow in rows:
> devices.append(eachrow.hostname)
> return dict(devices=devices)
>
>