3 ms·
There is one good reason to do it. To support JSONP (json with padding). If you use JSONP and the server sends an HTTP response code which is not 2XX, then the
by rahulrav 12y ago
There is one good reason to do it. To support JSONP (json with padding). If you use JSONP and the server sends an HTTP response code which is not 2XX, then the browser does not allow JavaScript to parse the response body at all.
There is a way to work around this, which is to use CORS. However, that is not supported in all browsers. So pick your poison.
- mcv 12y agoCORS is not a workaround; it's the right way to do it. JSONP is an ugly hack that should be avoided.