Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 45f47ff

Browse files
vojtajinaIgorMinar
authored andcommittedNov 30, 2011
fix($browser.xhr): change method "JSON" to "JSONP"
Breaks "JSON" xhr method is now called "JSONP"
1 parent 0c8b356 commit 45f47ff

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed
 

‎docs/content/cookbook/buzz.ngdoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ to retrieve Buzz activity and comments.
1818
this.Activity = $resource(
1919
'https://www.googleapis.com/buzz/v1/activities/:userId/:visibility/:activityId/:comments',
2020
{alt: 'json', callback: 'JSON_CALLBACK'},
21-
{ get: {method: 'JSON', params: {visibility: '@self'}},
22-
replies: {method: 'JSON', params: {visibility: '@self', comments: '@comments'}}
21+
{ get: {method: 'JSONP', params: {visibility: '@self'}},
22+
replies: {method: 'JSONP', params: {visibility: '@self', comments: '@comments'}}
2323
});
2424
}
2525
BuzzController.prototype = {

‎src/service/browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function Browser(window, document, body, XHR, $log, $sniffer) {
9999
*/
100100
self.xhr = function(method, url, post, callback, headers) {
101101
outstandingRequestCount ++;
102-
if (lowercase(method) == 'json') {
102+
if (lowercase(method) == 'jsonp') {
103103
var callbackId = ("angular_" + Math.random() + '_' + (idCounter++)).replace(/\d\./, '');
104104
window[callbackId] = function(data) {
105105
window[callbackId].data = data;

‎src/service/resource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* - `action` – {string} – The name of action. This name becomes the name of the method on your
4141
* resource object.
4242
* - `method` – {string} – HTTP request method. Valid methods are: `GET`, `POST`, `PUT`, `DELETE`,
43-
* and `JSON` (also known as JSONP).
43+
* and `JSONP`
4444
* - `params` – {object=} – Optional set of pre-bound parameters for this action.
4545
* - isArray – {boolean=} – If true then the returned object for this action is an array, see
4646
* `returns` section.
@@ -163,7 +163,7 @@
163163
this.Activity = $resource(
164164
'https://www.googleapis.com/buzz/v1/activities/:userId/:visibility/:activityId/:comments',
165165
{alt:'json', callback:'JSON_CALLBACK'},
166-
{get:{method:'JSON', params:{visibility:'@self'}}, replies: {method:'JSON', params:{visibility:'@self', comments:'@comments'}}}
166+
{get:{method:'JSONP', params:{visibility:'@self'}}, replies: {method:'JSONP', params:{visibility:'@self', comments:'@comments'}}}
167167
);
168168
}
169169

‎src/service/xhr.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
* {@link http://en.wikipedia.org/wiki/Rainbow_table salt for added security}.
8686
*
8787
* @param {string} method HTTP method to use. Valid values are: `GET`, `POST`, `PUT`, `DELETE`, and
88-
* `JSON`. `JSON` is a special case which causes a
88+
* `JSONP`. `JSONP` is a special case which causes a
8989
* [JSONP](http://en.wikipedia.org/wiki/JSON#JSONP) cross domain request using script tag
9090
* insertion.
9191
* @param {string} url Relative or absolute URL specifying the destination of the request. For
@@ -135,13 +135,13 @@
135135
<div ng:controller="FetchCntl">
136136
<select ng:model="method">
137137
<option>GET</option>
138-
<option>JSON</option>
138+
<option>JSONP</option>
139139
</select>
140140
<input type="text" ng:model="url" size="80"/>
141141
<button ng:click="fetch()">fetch</button><br>
142142
<button ng:click="updateModel('GET', 'index.html')">Sample GET</button>
143-
<button ng:click="updateModel('JSON', 'http://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero')">Sample JSONP</button>
144-
<button ng:click="updateModel('JSON', 'http://angularjs.org/doesntexist&callback=JSON_CALLBACK')">Invalid JSONP</button>
143+
<button ng:click="updateModel('JSONP', 'http://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero')">Sample JSONP</button>
144+
<button ng:click="updateModel('JSONP', 'http://angularjs.org/doesntexist&callback=JSON_CALLBACK')">Invalid JSONP</button>
145145
<pre>code={{code}}</pre>
146146
<pre>response={{response}}</pre>
147147
</div>

‎test/service/browserSpecs.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('browser', function() {
111111
});
112112

113113
describe('xhr', function() {
114-
describe('JSON', function() {
114+
describe('JSONP', function() {
115115
var log;
116116

117117
function callback(code, data) {
@@ -129,7 +129,7 @@ describe('browser', function() {
129129

130130
it('should add script tag for JSONP request', function() {
131131
var notify = jasmine.createSpy('notify');
132-
browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
132+
browser.xhr('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
133133
browser.notifyWhenNoOutstandingRequests(notify);
134134
expect(notify).not.toHaveBeenCalled();
135135
expect(scripts.length).toEqual(1);
@@ -148,7 +148,7 @@ describe('browser', function() {
148148

149149

150150
it('should call callback when script fails to load', function() {
151-
browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
151+
browser.xhr('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
152152
var script = scripts[0];
153153
expect(typeof script.onload).toBe('function');
154154
expect(typeof script.onerror).toBe('function');
@@ -160,7 +160,7 @@ describe('browser', function() {
160160

161161
it('should update the outstandingRequests counter for successful requests', function() {
162162
var notify = jasmine.createSpy('notify');
163-
browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
163+
browser.xhr('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
164164
browser.notifyWhenNoOutstandingRequests(notify);
165165
expect(notify).not.toHaveBeenCalled();
166166

@@ -175,7 +175,7 @@ describe('browser', function() {
175175

176176
it('should update the outstandingRequests counter for failed requests', function() {
177177
var notify = jasmine.createSpy('notify');
178-
browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
178+
browser.xhr('JSONP', 'http://example.org/path?cb=JSON_CALLBACK', null, callback);
179179
browser.notifyWhenNoOutstandingRequests(notify);
180180
expect(notify).not.toHaveBeenCalled();
181181

0 commit comments

Comments
 (0)
This repository has been archived.