Questions tagged [xmlhttprequest]

XMLHttpRequest (XHR) is a JavaScript object that exposes an API for making asynchronous HTTP requests from frontend code running a Web browser — that is, for enabling the programming technique known as AJAX. The XHR API is a legacy API. It has been superseded by the Fetch API.

Example usage

function reqListener () {
      console.log(this.responseText);
}
    
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://www.example.org/example.txt");
oReq.send();

Taken from mozilla.org.

See also

12041 questions
3
votes
0 answers

Timeouts on Ajax calls only on iOS and only on one specific mobile carrier (Rogers/Fido)

We have a web application making ajax requests to a backend and we get frequent but intermittent timeouts only when on an iPhone/iPad and only when using one specific mobile carrier (Rogers/Fido in Quebec, Canada). We completely isolated the problem…
mlessard
  • 513
  • 6
  • 13
3
votes
0 answers

Why `XMLHttpRequest.prototype.onload` throws Uncaught TypeError: Illegal invocation

try { XMLHttpRequest.prototype.onload } catch(e) { document.write(e) } I am trying to write a wrapper on XMLHttpRequest constructor, while this error throws. What is the reason?
jasonxia23
  • 147
  • 1
  • 12
3
votes
0 answers

Dart Throws No 'Access-Control-Allow-Origin' header error even though it is there

I have a basic go API server that serves up a "job" from the database and returns in in a JSON response with the Access-Control-Allow-Origin: * added to the header. func GetJob(w http.ResponseWriter, r *http.Request) { job := Job{} db, err =…
3
votes
1 answer

VBA doesn't read XMLHTTP request's response according to its tree structure

I have checked that both browser-generated page and VBA XMLHTTP request's string response have the same tree structure, with a tag being a child of aside. Unfortunately when I want to return bookie name, which is title attribute of a, I get an error…
Ryszard Jędraszyk
  • 2,296
  • 4
  • 23
  • 52
3
votes
0 answers

How to resume the aborted file request in JavaScript?

I would like to add pause and resume for my file upload. To pause the uploading, i have called abort method as below var xhr = new XMLHttpRequest(); xhr.abort() File paused as expected. But now i need to resume the paused file. How can I achieve…
Karthik Ravichandran
  • 1,205
  • 2
  • 15
  • 25
3
votes
2 answers

Spring boot: Do not send HSTS header

In a dev environment I have the problem that my browser (Yandex) redirects (307) an OPTIONS request to the https version of the URL. As we don't have SSL set up the request then fails with the error Response for preflight is invalid (redirect).
Leukipp
  • 550
  • 2
  • 9
  • 25
3
votes
1 answer

How to make chrome.webRequest wait for results of XMLHttpRequest();

I am working on a Chrome Extension where I want to block the loading of a page based on an external lookup (e.g., check a spam rating or other service based on the URL the user typed into the entry bar). From the Chrome Developer Docs, they provide…
Eric G
  • 907
  • 1
  • 9
  • 30
3
votes
5 answers

Do I have to keep checking if the XMLHttpRequest object exists?

I used to be a programmer but now do periodic "scripting." I'm trying to create an Ajax-based game. I have a .php file with the following javascript: if (window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (…
Mike Coble
  • 31
  • 3
3
votes
1 answer

Using XMLHttpRequest() in Transcrypt

I only have minimal JavaScript knowledge from coding a small API site entirely client-side. How would I use XMLHttpRequest() in Transcrypt? Or should I be using URLlib or something else? Is it as simple as creating a new XMLHttpRequest object and…
Sam
  • 43
  • 4
3
votes
1 answer

How to resend failed xmlHttpRequest

in my app I am trying to Handle failed xmlHttpRequest Authenticate Resend failed xmlHttpRequest I know how to catch error specialy for failed authorization with code 401: I have special case for this type of error. In this scenario I just want…
dtechlearn
  • 363
  • 2
  • 4
  • 21
3
votes
0 answers

XMLHttpRequest cannot work with webpack

i cannot load json from a local file with XMLHttpRequest in webpack. let returnJson = require('../assets/data/datas.json') console.log(returnJson) let xhr = new XMLHttpRequest() xhr.onreadystatechange = function() { if (xhr.readyState == 4 &&…
Laurent
  • 31
  • 2
3
votes
2 answers

ASP.Net MVC RC Unit Testing Ajax Requests

We have just started using ASP.Net MVC Release Candidate and the test project we have was previously testing Ajax requests with MVC beta. The old code looked something like this: Mock request = new…
Psiren
  • 484
  • 3
  • 9
3
votes
3 answers

Why there is no response back from XMLHttpRequest?

I'm truing to get some results from a PHP file connected to a DB , But the variable that is sent to the DB is not sent from the XMLHttpRequest . The HTML: Here is the JS: var uname =…
Sam
  • 163
  • 4
  • 10
3
votes
1 answer

Refused to get unsafe header "Location" in chrome and no content in firefox

I am trying to upload an file to ovh object storage (openstack swift), but run into issues. In Chrome I get: Refused to get unsafe header "Location" I tried solving this with by adding 'Access-Control-Expose-Headers': 'Location' to the request…
musicformellons
  • 12,283
  • 4
  • 51
  • 86
3
votes
4 answers

How to fix CORS issue http request in Angular 5

I am new in Angular 5, and I want to send http request but it return CORS error in inspect element. Error XMLHttpRequest cannot load http://example.com/account/create. Response to preflight request doesn't pass access control check: No…
Sharma Vikram
  • 2,440
  • 6
  • 23
  • 46
1 2 3
99
100