Skip to content

Commit

Permalink
Fix use of timeout property for synchronous XMLHttpRequests
Browse files Browse the repository at this point in the history
Convert XMLHttpRequests to be asynchronous to allow for the use of the
timeout property. The timeout property can't be used for synchronous
requests in a document environment (window/iframe) or an
`InvalidAccessError` is thrown.
  • Loading branch information
bscuron committed May 14, 2024
1 parent 48cfd69 commit 054c031
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ export function request (url, params, callback, context) {

// ie10/11 require the request be opened before a timeout is applied
if (requestLength <= 2000 && Support.cors) {
httpRequest.open('GET', url + '?' + paramString);
httpRequest.open('GET', url + '?' + paramString, true);
} else if (requestLength > 2000 && Support.cors) {
httpRequest.open('POST', url);
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
}

Expand Down

0 comments on commit 054c031

Please sign in to comment.