aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax
Commit message (Collapse)AuthorAgeFilesLines
* Core: Use named exports in `src/`Michał Gołębiowski-Owczarek2023-09-128-12/+12
| | | | | | | | | 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: Don't treat array data as binaryMichał Gołębiowski-Owczarek2023-03-211-0/+1
| | | | | | | | | | | | | PR gh-5197 started treating all non-string non-plain-object `data` values as binary. However, `jQuery.ajax` also supports arrays as values of `data`. This change makes regular arrays no longer be considered binary data. Surprisingly, we had no tests for array `data` values; otherwise, we'd detect the issue earlier. This change also adds a few such missing tests. Closes gh-5203 Ref gh-5197
* Ajax: Allow `processData: true` even for binary dataMichał Gołębiowski-Owczarek2023-03-201-2/+5
| | | | | | | | | | The way gh-5197 implemented binary data handling, `processData` was being explicitly set to `false`. This is expected but it made it impossible to override it to `true`. The new logic will only set `processData` to `false` if it wasn't explicitly passed in original options. Closes gh-5205 Ref gh-5197
* Ajax: Support binary data (including FormData)Michał Gołębiowski-Owczarek2023-02-011-0/+17
| | | | | | | | | | | | Two changes have been applied: * prefilters are now applied before data is converted to a string; this allows prefilters to disable such a conversion * a prefilter for binary data is added; it disables data conversion for non-string non-plain-object `data`; for `FormData` bodies, it removes manually-set `Content-Type` header - this is required as browsers need to append their own boundary to the header Ref gh-4150 Closes gh-5197
* 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: Support `null` as success functions in `jQuery.get`Michał Gołębiowski-Owczarek2022-10-171-1/+0
| | | | | | | | | | | | | According to the docs, one can use `null` as a success function in `jQuery.get` of `jQuery.post` so the following: ```js await jQuery.get( "https://httpbin.org/json", null, "text" ) ``` should get the text result. However, this shortcut hasn't been working so far. Fixes gh-4989 Closes gh-5139
* Docs: Replace `#NUMBER` Trac issue references with `trac-NUMBER`Michał Gołębiowski-Owczarek2022-01-041-2/+2
| | | | | | | | | | | | | The GitHub UI treats `#NUMBER` as referring to its own issues which is confusing when in jQuery source it's usually referring to the old deprecated Trac instance at https://bugs.jquery.com. This change replaces all such Trac references with `trac-NUMBER`. A few of the references came with the Sizzle integration and referred to the Sizzle GitHub bug tracker. Those have been replaced with full links instead. A new entry describing issue reference conventions has been added to README. Closes gh-4993
* 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
* Ajax: Drop the json to jsonp auto-promotion logicMichał Gołębiowski-Owczarek2020-07-271-52/+48
| | | | | | | | | | | | | | | | | | | | Previously, `jQuery.ajax` with `dataType: 'json'` with a provided callback was automatically converted to a jsonp request unless one also specified `jsonp: false`. Today the preferred way of interacting with a cross-domain backend is CORS which works in all browsers jQuery 4 will support. Auto-promoting JSON requests to JSONP ones introduces a security issue as the developer may be unaware they're not just downloading data but executing code from a remote domain. This commit disables the auto-promoting logic. BREAKING CHANGE: to trigger a JSONP request, it's now required to specify `dataType: "jsonp"`; previously some requests with `dataType: "json"` were auto-promoted to JSONP. Fixes gh-1799 Fixes gh-3376 Closes gh-4754
* Build: Correct code indentations based on jQuery Style GuideWonseop Kim2020-05-051-3/+3
| | | | | | | | 1. Correct code indentations based on jQuery Style Guide (contribute.jquery.org/style-guide/js/#spacing). 2. Add rules to "src/.eslintrc.json" to enable "enforcing consistent indentation", with minimal changes to the current code. Closes gh-4672
* Build:Tests: Fix custom build tests, verify on Travis Michał Gołębiowski-Owczarek2020-01-071-24/+0
| | | | | | | | | | | This commit fixes unit tests for the following builds: 1. The no-deprecated build: `custom:-deprecated` 2. The current slim build: `custom:-ajax,-effects` 3. The future (#4553) slim build: `custom:-ajax,-callbacks,-deferred,-effects` It also adds separate Travis jobs for the no-deprecated & slim builds. Closes gh-4577
* Core: Migrate from AMD to ES modules 🎉Michał Gołębiowski-Owczarek2019-11-188-60/+22
| | | | | | | | | | | | | | | | | | | | | | 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
* Ajax: Simplify jQuery.ajaxSettings.xhrMichał Gołębiowski-Owczarek2019-08-261-3/+1
| | | | | | | | | | | | | | | Previously, jQuery.ajaxSettings.xhr, contents were wrapped in a try-catch as we defined jQuery.support.ajax & jQuery.support.cors executed during the jQuery load and we didn't want to crash if IE had native XHR disabled (which is possible). While jQuery hasn't supported the ActiveX-based XHR since 2.0, jQuery with XHR disabled could still be used for its other features in such a crippled browser. Since gh-4347, jQuery.support.ajax & jQuery.support.cors no longer exist, so we don't need the try-catch anymore. Fixes gh-1967 Closes gh-4467 Ref gh-4347
* Core: Drop support for IE <11, iOS <11, Firefox <65, Android Browser & PhantomJSMichał Gołębiowski-Owczarek2019-04-294-141/+91
| | | | | | | | | | | Also, update support comments format to match format described in: https://github.com/jquery/contribute.jquery.org/issues/95#issuecomment-69379197 with the change from: https://github.com/jquery/contribute.jquery.org/issues/95#issuecomment-448998379 (open-ended ranges end with `+`). Fixes gh-3950 Fixes gh-4299 Closes gh-4347
* 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`.
* Core: deprecate jQuery.isFunctionJason Bedard2018-01-152-5/+7
| | | | Fixes gh-3609
* Core: deprecate jQuery.nowTimmy Willison2018-01-081-4/+2
| | | | | Fixes gh-2959 Close gh-3884
* Ajax: add an ontimeout handler to all requestsErik Lax2017-07-241-2/+3
| | | | | Fixes gh-3586 Close gh-3590
* Core: rnotwhite -> rhtmlnotwhite and jQuery.trim -> stripAndCollapseTimmy Willison2016-09-151-2/+3
| | | | | | | | | | | | - Renames and changes rnotwhite to focus on HTML whitespace chars - Change internal use of jQuery.trim to more accurate strip and collapse - Adds tests to ensure HTML space characters are retained where valid - Doesn't add tests where the difference is inconsequential and existing tests are adequate. Fixes gh-3003 Fixes gh-3072 Close gh-3316
* Build: Put all AMD modules in "src/" in strict modeMichał Gołębiowski2016-04-258-0/+16
| | | | Fixes gh-3073
* Ajax: execute jQuery#load callback with correct contextOleg Gaidarenko2016-04-041-1/+1
| | | | | | | Thanks @blq (Fredrik Blomqvist) Fixes gh-3035 Close gh-3039
* Docs: Update support comments to follow the new syntaxMichał Gołębiowski2016-03-302-5/+5
| | | | | The changes follow the spec proposed in: https://github.com/jquery/contribute.jquery.org/issues/95#issuecomment-69379197
* Docs:Tests: Remove obsolete code from tests, update support commentsMichał Gołębiowski2016-03-082-4/+5
| | | | | | | | | | Support comments that were lacking the final IE/Edge version that exhibits the bug were checked & updated. Links to the Chromium bug tracker were updated. Code in tests related to unsupported browsers (like Android 2.3 in non-basic tests) has been removed. Fixes gh-2868 Closes gh-2949
* Core: Deprecate jQuery.parseJSONMichał Gołębiowski2016-03-021-9/+0
| | | | | Fixes gh-2800 Closes gh-2948
* Ajax: Don't throw exceptions on binary data responseDave Methvin2015-11-041-6/+7
| | | | | | | | | Fixes gh-2498 Closes gh-2682 The added unit test shows how this could be used to support an ArrayBuffer return, but $.ajax does not support it natively. The goal with this change was to avoid the exception.
* Ajax: trigger error callback on native abortTimmy Willison2015-11-031-8/+41
| | | | | | | - IE9 does not have onabort. Use onreadystatechange instead. Fixes gh-2079 Close gh-2684
* 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
* Ajax:Attributes:CSS:Manipulation: Reduce Android 2.3 supportMichał Gołębiowski2015-09-141-5/+1
| | | | | | | | Drop non-critical workarounds for Android 2.3. Fixes gh-2483 Fixes gh-2505 Closes gh-2581
* Build: Update jscs and lint filesOleg Gaidarenko2015-09-079-50/+59
| | | | Fixes gh-2056
* Ajax: Remove jsonp callbacks through "jQuery#removeProp" methodOleg Gaidarenko2015-07-131-2/+8
| | | | | Fixes gh-2323 Closes gh-2464
* Ajax: Remove remnants of the load event alias handlingMichał Gołębiowski2015-06-011-10/+1
| | | | | | Refs 0705be475092aede1eddae01319ec931fb9c65fc Refs gh-2287 Closes gh-2362
* Ajax: remove "onunload" event handlerOleg Gaidarenko2015-05-031-18/+3
| | | | | | | | | Remove hack for IE lost connections, update for it was released by Microsoft at November 12, 2013. See https://support.microsoft.com/en-us/kb/2905733 Ref trac-5280 Ref gh-2047
* Core: Align branches: remove an unused variable, add commentsMichał Gołębiowski2015-04-271-0/+2
| | | | Closes gh-2233
* Ajax: remove use of jQuery#each second argumentOleg Gaidarenko2015-02-191-1/+3
| | | | Ref gh-2090
* Ajax: replace "jqXHR.complete" callback with "always"Oleg Gaidarenko2015-02-151-1/+4
| | | | | | | | | Since it was deprecated since 1.8. Also add additional comments which explains tricky behaviour of "always" callback Closes gh-2033
* Ajax: make jQuery#load "type" field explicitOleg Gaidarenko2015-02-151-2/+4
| | | | | | | | * Move "evalScript.php" file to appropriate place * Make jQuery#load "type" field explicit and add test for it Ref trac-11264
* 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
* Core: Standardize indexOf comparisonsRichard Gibson2015-01-102-2/+3
| | | | | | | | not present: `< 0` present: `> -1` at index: `=== N` Closes gh-1984
* Build: Don't assume the browser environment; smoke test on Node w/ jsdomMichał Gołębiowski2014-12-264-3/+7
| | | | | Fixes gh-1950 Closes gh-1949
* Ajax: simplify jQuery.parseXML methodShivaji Varma2014-12-251-3/+2
| | | | | | | | | -2 bytes to the gzipped size and code looks a bit nicer This wasn't landed to the compat branch though, since size would increase with this cherry-pick Closes gh-1856
* Ajax: remove event dependency from the ajax moduleOleg Gaidarenko2014-10-141-2/+3
| | | | Closes gh-1695
* Build: update grunt-jscs-checker and pass with the new rulesTimmy Willison2014-07-173-4/+13
|
* Ajax: .load() should trim its selectorDave Methvin2014-03-041-1/+1
| | | | Fixes #14773
* Ajax: Protect against exceptions thrown synchronously by xhr.sendjaubourg2014-01-291-4/+9
| | | | | | | | | | | When xhr.send throws an exception synchronously, the onerror handler may have been called already which, unchecked, makes the exception bubble up outside of jQuery.ajax. We now catch the exception pre-emptively and only rethrow if we know it hasn't already been notified through the onerror handler. Fixes #14683
* Revert "Ajax: Fix #14424. Use ActiveX in IE9+ on local files, close gh-1434."Dave Methvin2013-12-151-8/+0
| | | | | | This reverts commit 498e0e6c9bf486a0b1f16b455d65fcbc6c43867e. We can't use the ActiveX XHR because it doesn't support events.