5 ms·
I was once tasked with creating a new frontend on an old project that had an API endpoint return something like this: var array = ["foo", "bar"] I was expec
by mxrlkn 5y ago
I was once tasked with creating a new frontend on an old project that had an API endpoint return something like this:
var array = ["foo", "bar"]
I was expecting xml or json (like the rest of the endpoints), but I realized that they just served this as text, and then eval'd it on the frontend...
- david2ndaccount 5y agoThis was how you used to do it before JSON.parse was built into the browser.
- zmmmmm 5y agoit was literally a pseudo "standard": https://en.wikipedia.org/wiki/JSONP https://en.wikipedia.org/wiki/JSONP
- mxrlkn 5y agoRight, but for it to be JSONP, the response should be injected into a script tag, I believe.
- tentacleuno 5y agoAnd it should be wrapped in a function call (most times, you can choose which function is called by a query parameter).