Skip to content

Commit f6f8df3

Browse files
committed
Added some additional documentation on JSONP loading, based on Chrome behaviour with mime types
1 parent a8d1f8f commit f6f8df3

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/preloadjs/loaders/JSONPLoader.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ this.createjs = this.createjs || {};
6868
* console.log(json.obj.bool); // true
6969
* }
7070
*
71-
* Note that JSONP files loaded concurrently require a <em>unique</em> callback. To ensure JSONP files are loaded
72-
* in order, either use the {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}} method (set to 1),
73-
* or set {{#crossLink "LoadItem/maintainOrder:property"}}{{/crossLink}} on items with the same callback.
71+
* JSONP files loaded concurrently require a <em>unique</em> callback. To ensure JSONP files are loaded in order,
72+
* either use the {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}} method (set to 1), or set
73+
* {{#crossLink "LoadItem/maintainOrder:property"}}{{/crossLink}} on items with the same callback.
74+
*
75+
* Important note: Some browsers will prevent JSONP from firing the callback if the file was loaded as JSON, and not
76+
* JavaScript. You may have to have your server give you a JavaScript mime-type for this to work.
7477
*
7578
* @class JSONPLoader
7679
* @param {LoadItem|Object} loadItem

src/preloadjs/loaders/ManifestLoader.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ this.createjs = this.createjs || {};
6161
* Note that the {{#crossLink "JSONLoader"}}{{/crossLink}} and {{#crossLink "JSONPLoader"}}{{/crossLink}} are
6262
* higher priority loaders, so manifests <strong>must</strong> set the {{#crossLink "LoadItem"}}{{/crossLink}}
6363
* {{#crossLink "LoadItem/type:property"}}{{/crossLink}} property to {{#crossLink "AbstractLoader/MANIFEST:property"}}{{/crossLink}}.
64+
*
65+
* Additionally, some browsers require the server to serve a JavaScript mime-type for JSONP, so it may not work in
66+
* some conditions.
6467
* @class ManifestLoader
6568
* @param {LoadItem|Object} loadItem
6669
* @extends AbstractLoader
6770
* @constructor
6871
*/
69-
function ManifestLoader(loadItem) {
70-
this.AbstractLoader_constructor(loadItem, null, createjs.AbstractLoader.MANIFEST);
72+
function ManifestLoader(loadItem, preferXHR) {
73+
this.AbstractLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.MANIFEST);
7174

7275
// Public Properties
7376
/**
@@ -164,7 +167,7 @@ this.createjs = this.createjs || {};
164167
*/
165168
p._loadManifest = function (json) {
166169
if (json && json.manifest) {
167-
var queue = this._manifestQueue = new createjs.LoadQueue();
170+
var queue = this._manifestQueue = new createjs.LoadQueue(this._preferXHR);
168171
queue.on("fileload", this._handleManifestFileLoad, this);
169172
queue.on("progress", this._handleManifestProgress, this);
170173
queue.on("complete", this._handleManifestComplete, this, true);

0 commit comments

Comments
 (0)