Reputation: 894
Why do browsers allow cross-origin JSONP requests and do not allow JSON requests? I know that JSON requests are not allowed to prevent XSS, but I don't see how JSONP is safer than JSON.
In fact, could JSONP be even more dangerous because it is technically a script, where JSON is just a text string?
Upvotes: 2
Views: 232
Reputation: 894
Because cross-domain JSON is blocked, sensitive data can be transmitted using JSON, rather than JSONP. This prevents XSS. Additionally, a server should not send sensitive data using JSONP. Thus, sending data using JSON protects it from unauthorized observation. JSON is safer in this sense.
Upvotes: 0