Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Remo API with $.getJSON

43 views
Skip to first unread message

Mouhamadou M CAMARA

unread,
Jan 17, 2013, 6:43:50 AM1/17/13
to reps-...@lists.mozilla.org
Hi guys


I would like to make a simple web App for the Firefox APP days demo in
Dakar.
For that, i use the ReMo API like that :

$.getJSON("https://reps.mozilla.org/api/v1/rep/?format=json&limit=10",
function(data) {

// to debug

console.log(data);

// use moctar List view to list Reps
...
});

but nothing is returned

I tried to use twitter search to see if my code is correct just changing
the url by
"http://search.twitter.com/search.json?q=FirefoxOSAppDays&rpp=0&callback=?"
and that correct

I would like to know where is the problem ?

I have also add "&callback=?" for callback function but i have an error
on console "SyntaxError: invalid label"


Sorry for my english


great

John Giannelos

unread,
Jan 17, 2013, 8:21:44 AM1/17/13
to reps-...@lists.mozilla.org
Hi,

I assume that the reason why $.getJSON is not working is because you are
trying to load a json from a different domain,
which is not allowed by web browsers.

To avoid this you can use JSONP [1]
Here [2] you can see an example JSONP API request for reps.mozilla.org.
Sorry for the ugly formatting :)

~nemo

[1] http://en.wikipedia.org/wiki/JSONP
[2] http://jsfiddle.net/TaYDB/
> _______________________________________________
> reps-webdev mailing list
> reps-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/reps-webdev
>

Leo Balter

unread,
Jan 17, 2013, 8:44:17 AM1/17/13
to reps-...@lists.mozilla.org
remember you may still have problems making requests to a https protocol if your app is using only http.

the cross domain issue is still the main problem and you could try a $.ajax calling a Jsonp, not a real json.

I'm not sure if you could call the api via http, if not, it would be easier if you migrate all your resources to the same protocol.

Leo Balter - via mobile

Leo Balter

unread,
Jan 17, 2013, 8:48:22 AM1/17/13
to reps-...@lists.mozilla.org
just checking: you call also call the api from http, so you can change to the apropriated protocol or you can use a trick to always follow the same protocol you are using:

//reps.mozilla.org/api/v1/rep/?format=json&limit=10

Now you only need to change the te request to a jsonp. This way your app will work using both http abd https.

cheers

Leo Balter - via mobile

Mouhamadou Moustapha Camara

unread,
Jan 18, 2013, 5:24:31 AM1/18/13
to reps-...@lists.mozilla.org
Hi guys

Thant you very much for your response that work fine with using JSONP i'll
try to use other solution may be one day he can help me

Great

Mouhamadou Moustapha CAMARA aka mmkmou
Mozilla Senegal Community Lead / Mozilla Reps
http://mmkmou.net / http://mozilla-senegal.org
__________________________________________
we make a better world <mmk...@mozilla-senegal.org>


2013/1/17 Leo Balter <leonard...@gmail.com>
0 new messages