You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
feat($http): specify the JSONP callback via the callbackParam config value
The query parameter that will be used to transmit the JSONP callback to the
server is now specified via the `callbackParam` config value, instead of
using the `JSON_CALLBACK` placeholder.
* Any use of `JSON_CALLBACK` in a JSONP request URL will cause an error.
* Any request that provides a parameter with the same name as that given
by the `callbackParam` config property will cause an error.
This is to prevent malicious attack via the response from an app inadvertently
allowing untrusted data to be used to generate the callback parameter.
BREAKING CHANGE
You can no longer use the `JSON_CALLBACK` placeholder in your JSONP requests.
Instead you must provide the name of the query parameter that will pass the
callback via the `callbackParam` property of the config object, or app-wide via
the `$http.defaults.callbackParam` property, which is `callback` by default.
Before this change:
```
$http.json('trusted/url?callback=JSON_CALLBACK');
$http.json('other/trusted/url', {params:cb:'JSON_CALLBACK'});
```
After this change:
```
$http.json('trusted/url');
$http.json('other/trusted/url', {callbackParam:'cb'});
```
This error occurs when the URL generated from the configuration object contains a parameter with the same name as the configured `callbackParam`
7
+
property; or when it contains a parameter whose value is `JSON_CALLBACK`.
8
+
9
+
`$http` JSON requests need to attach a callback query parameter to the URL. The name of this parameter is specified in the configuration
10
+
object (or in the defaults) via the `callbackParam` property. You must not provide your own parameter with this name in the configuration
11
+
of the request.
12
+
13
+
In previous versions of Angular, you specified where to add the callback parameter value via the `JSON_CALLBACK` placeholder. This is no longer
14
+
allowed.
15
+
16
+
To resolve this error, remove any parameters that have the same name as the `callbackParam`; and/or remove any parameters that have a value of `JSON_CALLBACK`.
17
+
18
+
For more information, see the {@link ng.$http#jsonp `$http.jsonp()`} method API documentation.
0 commit comments