Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
mxrlkn
· 5y ago · 0 comments
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...
Comments
[–]
david2ndaccount
5y ago
This was how you used to do it before JSON.parse was built into the browser.
[–]
zmmmmm
5y ago
it was literally a pseudo "standard":
https://en.wikipedia.org/wiki/JSONP
[–]
mxrlkn
OP
5y ago
Right, but for it to be JSONP, the response should be injected into a script tag, I believe.
[–]
tentacleuno
5y ago
And it should be wrapped in a function call (most times, you can choose which function is called by a query parameter).