aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax/script.js
Commit message (Collapse)AuthorAgeFilesLines
* Core: Use named exports in `src/`Michał Gołębiowski-Owczarek2023-09-121-2/+2
| | | | | | | | | The `default` export is treated differently across tooling when transpiled to CommonJS - tools differ on whether `module.exports` represents the full module object or just its default export. Switch `src/` modules to named exports for tooling consistency. Fixes gh-5262 Closes gh-5292
* Ajax: Support `headers` for script transport even when cross-domainMichał Gołębiowski-Owczarek2023-02-011-10/+18
| | | | | | | | | | | | | | | | The AJAX script transport has two versions: XHR + `jQuery.globalEval` or appending a script tag (note that `jQuery.globalEval` also appends a script tag now, but inline). The former cannot support the `headers` option which has so far not been taken into account. For jQuery 3.x, the main consequence was the option not being respected for cross-domain requests. Since in 4.x we use the latter way more often, the option was being ignored in more cases. The transport now checks whether the `headers` option is specified and uses the XHR way unless `scriptAttrs` are specified as well. Fixes gh-5142 Closes gh-5193
* Ajax: Don't auto-execute scripts unless dataType providedMichał Gołębiowski-Owczarek2021-01-261-11/+2
| | | | | | | | | | | | | | PR gh-2588 made jQuery stop auto-execute cross-domain scripts unless `dataType: "script"` was explicitly provided; this change landed in jQuery 3.0.0. This change extends that logic same-domain scripts as well. After this change, to request a script under a provided URL to be evaluated, you need to provide `dataType: "script` in `jQuery.ajax` options or to use `jQuery.getScript`. Fixes gh-4822 Closes gh-4825 Ref gh-2432 Ref gh-2588
* Ajax: Make responseJSON work for erroneous same-domain JSONP requestsMichał Gołębiowski-Owczarek2020-09-011-5/+18
| | | | | | | | | | | | | | | | Don't use a script tag for JSONP requests unless for cross-domain requests or if scriptAttrs are provided. This makes the `responseJSON` property available in JSONP error callbacks. This fixes a regression from jQuery 3.5.0 introduced in gh-4379 which made erroneous script responses to not be executed to follow native behavior. The 3.x-stable branch doesn't need this fix as it doesn't use script tags for regular async requests. Closes gh-4778 Ref gh-4771 Ref gh-4773 Ref gh-4379
* Ajax: Avoid CSP errors in the script transport for async requestsMichał Gołębiowski-Owczarek2020-08-251-3/+7
| | | | | | | | | | | | | | | | | Until now, the AJAX script transport only used a script tag to load scripts for cross-domain requests or ones with `scriptAttrs` set. This commit makes it also used for all async requests to avoid CSP errors arising from usage of inline scripts. This also makes `jQuery.getScript` not trigger CSP errors as it uses the AJAX script transport under the hood. For sync requests such a change is impossible and that's what `jQuery._evalUrl` uses. Fixing that is tracked in gh-1895. The commit also makes other type of requests using the script tag version of the script transport set its type to "GET", namely async scripts & ones with `scriptAttrs` set in addition to the existing cross-domain ones. Fixes gh-3969 Closes gh-4763
* Core: Migrate from AMD to ES modules 🎉Michał Gołębiowski-Owczarek2019-11-181-8/+3
| | | | | | | | | | | | | | | | | | | | | | Migrate all source AMD modules to ECMAScript modules. The final bundle is compiled by a custom build process that uses Rollup under the hood. Test files themselves are still loaded via RequireJS as that has to work in IE 11. Tests can now be run in "Load as modules" mode which replaces the previous "Load with AMD" option. That option of running tests doesn't work in IE and Edge as it requires support for dynamic imports. Some of the changes required by the migration: * check `typeof` of `noGlobal` instead of using the variable directly as it's not available when modules are used * change the nonce module to be an object as ECMASscript module exports are immutable * remove some unused exports * import `./core/parseHTML.js` directly in `jquery.js` so that it's not being cut out when the `ajax` module is excluded in a custom compilation Closes gh-4541
* squash! Set attributes all at once, src lastDave Methvin2018-05-141-8/+5
|
* Ajax: Allow custom attributes when script transport is usedDave Methvin2018-05-141-3/+3
| | | | | | | Fixes gh-3028 Ref gh-2612 Useful, for example, to add `nonce`, `integrity`, or `crossorigin`.
* Build: Put all AMD modules in "src/" in strict modeMichał Gołębiowski2016-04-251-0/+2
| | | | Fixes gh-3073
* Ajax: improve content-type detectionOleg Gaidarenko2015-10-121-1/+1
| | | | | Fixes gh-2584 Closes gh-2643
* Ajax: correct indentationOleg Gaidarenko2015-10-121-3/+3
| | | | | | As noted by @arthurvr Follow-up for b078a62013782c7424a4a61a240c23c4c0b42614
* Ajax: Mitigate possible XSS vulnerabilityOleg Gaidarenko2015-10-121-0/+7
| | | | | | | Proposed by @jaubourg Fixes gh-2432 Closes gh-2588
* Build: Update jscs and lint filesOleg Gaidarenko2015-09-071-8/+9
| | | | Fixes gh-2056
* Core: Align branches: remove an unused variable, add commentsMichał Gołębiowski2015-04-271-0/+2
| | | | Closes gh-2233
* Ajax: simplify one ajax call and add explanatory commentOleg Gaidarenko2015-02-151-1/+0
| | | | | | | * Remove "async = true" from script transport since it was needed for FF < 4 and old Opera which we do not support anymore * Add comment to "evalUrl" method on why "type" field should be explicit
* Build: Don't assume the browser environment; smoke test on Node w/ jsdomMichał Gołębiowski2014-12-261-1/+2
| | | | | Fixes gh-1950 Closes gh-1949
* Build: update grunt-jscs-checker and pass with the new rulesTimmy Willison2014-07-171-1/+2
|
* AMD-ify jQuery sourcegit s! Woo! Fixes #14113, #14163.Timmy Willison2013-08-151-0/+7
|
* Removes unnecessary call to `.off()` as noted by @dcherman.jaubourg2013-01-211-1/+1
|
* Further script transport cleanup, close gh-1123.jaubourg2013-01-201-19/+16
|
* Reduced script transportjaubourg2013-01-201-47/+21
|
* No ticket: compress ajax. Close gh-1041.Richard Gibson2012-11-251-9/+10
|
* Set async to true instead of async (prop vs. attr). Closes gh-1039Timo Tijhof2012-11-211-1/+1
|
* Strips IIFEs from modules; Always require built jQuery for tests.Rick Waldron2012-06-041-4/+0
|
* Applies exception in Style Guidelines regarding objects and functions when ↵jaubourg2011-04-081-2/+2
| | | | they are the last argument of a function call.
* Fixes #8744. Makes sure script transport abort method actually removes the ↵jaubourg2011-04-041-1/+1
| | | | script tag even if readyState exists.
* Fixes #8098. Use the fast document.head when available. Don't set unneeded ↵Mathias Bynens2011-02-021-1/+1
| | | | "script.type = text/javascript".
* Script dataType now supports ecmascript mimetypes.jaubourg2011-01-311-2/+2
|
* Fixes #8082. Text to script converter now returns text. Unit test added.jaubourg2011-01-291-1/+4
|
* More code style fixes.jaubourg2011-01-231-1/+1
|
* Apply JQuery Core Style Guidelines to ajax.js and ajax/*.js,jaubourg2011-01-231-17/+12
|
* Cleans up and simplifies code shared by ajaxPrefilter and ajaxTransport. ↵jaubourg2011-01-201-2/+4
| | | | Removes chainability of ajaxSetup, ajaxPrefilter and ajaxTransport. Also makes sure context is handled properly by ajaxSetup (unit test added).
* The script prefilter now forces cross-domain requests type to GET.jaubourg2011-01-161-0/+1
|
* Fixes #2994. Not finding a transport now fires the error callbacks and ↵jaubourg2011-01-161-6/+10
| | | | doesn't make ajax return false. Had to revise how jsonp and script prefilters & transports work (better separation of concerns). Also took the opportunity to revise jXHR getRequestHeader and abort methods and enabled early transport garbage collection when the request completes.
* Moved jQuery.ajax.prefilter and jQuery.ajax.transport to ↵jaubourg2011-01-131-2/+1
| | | | jQuery.ajaxPrefilter and jQuery.ajaxTransport so that proxying the ajax method doesn't turn into a nightmare. Thanks go to scott_gonzalez and DaveMethvin for pointing out the issue. Also made ajaxSetup return "this" to enable chainable definitions -- jQuery.ajaxSetup(...).ajaxPrefilter(...).ajaxTransport(...).
* Reworked script and xhr abort logic to take advantage of the fact jXHR.abort ↵jaubourg2011-01-131-5/+8
| | | | will complete the request itself if not done already.
* Script transport now uses ajaxSetup to define script dataType.jaubourg2011-01-121-3/+3
|
* Renamed src/transports to src/ajax (in case we need prefilters in the future ↵jaubourg2011-01-061-0/+82
and to avoid a separate prefilters directory).