3 ms·
> If you allow trailing commas then you would break json parsing in all old version of IE. No, you would break the evaluation of json as javascript in old vers
by masklinn 13y ago
> If you allow trailing commas then you would break json parsing in all old version of IE.
No, you would break the evaluation of json as javascript in old versions of IE.
Use a real parser already.
- jcampbell1 13y agoI do use a real parser, but it is not possible for JSON-P.
- jonny_eh 13y agoDon't use JSONP.
- jcampbell1 13y agoI suppose you have a better way to do cross-platform cross-domain APIs? Enlighten us. Facebook and Google use this method, and I assume it is because there isn't a better way.
- bdisraeli 13y agoYou can use CORS [1] on browsers that support it. [2] You really should use it if at all possible given your application's constraints, so you don't have to abuse GET requests and can use a JSON parser. [1] http://en.m.wikipedia.org/wiki/Cross-origin_resource_sharing http://en.m.wikipedia.org/wiki/Cross-origin_resource_sharing [2] http://caniuse.com/cors http://caniuse.com/cors
- zenojevski 13y agoI've always avoided JSONP, but this would seem doable. What am I missing? callback(JSON.parse('{ "key":"value" }')) Or even directly parsing the string inside of the callback.