mfratto
Posts: 0
Joined: Tue Aug 23, 2011 11:13 pm

displaying returned data from json vs jsonp

what's the story with json vs jsonp? I am trying to use some json feeds from broadbandmap.gov http://www.broadbandmap.gov/broadband...) and when I build the data and test the REST service as json, I can see the fields and I can map them. Using jsonp, the service returns an error.

However, I can't see any results in the app when I test it.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

displaying returned data from json vs jsonp

It's a default security feature. When using json, you can only invoke services from the same domain from which the page was loaded. For example, if the page was loaded from mydomain.com, you can only invoke services from mydomain.com. It works inside Tiggr as it's not coming from a web page.

jsonp is a (standard) workaround (http://en.wikipedia.org/wiki/JSONP), to make it possible to invoke services from a different domain. So, when the page is loaded from gotiggr.com, you can invoke services from broadbandmap.com.

mfratto
Posts: 0
Joined: Tue Aug 23, 2011 11:13 pm

displaying returned data from json vs jsonp

Max, thanks. So the problem is that when I set data type to jsonp, the service returns "406, Not Acceptable."

I am guessing that jsonp as to be supported at the service, yah?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

displaying returned data from json vs jsonp

Sorry, I got it wrong. Tiggr is not sending the right header information when using jsonp. If you add this request param: accept=application/json -- service Test works fine with jsonp.

mfratto
Posts: 0
Joined: Tue Aug 23, 2011 11:13 pm

displaying returned data from json vs jsonp

OK, that works.

I am still not getting data displayed on the screen. I mapped the array to the grid and then the two fields to display labels. I am not seeing it populate.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

displaying returned data from json vs jsonp

Please share the project with a href="mailto:support@gotiggr.com" rel="nofollow"support@gotiggr.com/a, I'll take a look at the service/mappings. Here is how to share: http://help.gotiggr.com/documentation...

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

displaying returned data from json vs jsonp

Fixed. We set format=jsonp. Every service out there works in slightly different way.

mfratto
Posts: 0
Joined: Tue Aug 23, 2011 11:13 pm

displaying returned data from json vs jsonp

huh. Thanks.

Just so I know in the future, it's a matter of finding the right combination of setting the format as a header, datatype, and argument.

I was reading the broadband.gov API, and they ask for a call back for jsonp. I take it that tiggr automatically adds the callback?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

displaying returned data from json vs jsonp

Yes, it's automatically added by jQuery Mobile. But if needed, you can specify the callback function yourself.

Return to “Issues”