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
73
votes
2 answers

Upload file with Ajax XMLHttpRequest

I am trying to send file with XMLHttpRequest with this code. var url= "http://localhost:80/...."; $(document).ready(function(){ document.getElementById('upload').addEventListener('change', function(e) { var file = this.files[0]; …
Sedat Başar
  • 3,740
  • 3
  • 25
  • 28
73
votes
11 answers

Page loaded over HTTPS but requested an insecure XMLHttpRequest endpoint

I have a page with some D3 javascript on. This page sits within a HTTPS website, but the certificate is self-signed. When I load the page, my D3 visualisations do not show, and I get the error: Mixed Content: The page at…
J86
  • 14,345
  • 47
  • 130
  • 228
72
votes
8 answers

How can I download and save a file using the Fetch API? (Node.js)

I have the url to a possibly large (100+ Mb) file, how do I save it in a local directory using fetch? I looked around but there don't seem to be a lot of resources/tutorials on how to do this. Thank you!
Gloomy
  • 1,091
  • 1
  • 9
  • 18
72
votes
3 answers

Why is it called XMLHttpRequest?

I always wonder why this object is called like that? The body of your request does not need to be in XML format. Also, data received from server can be fetched as JSON, XML, HTML, or plain text. XML does not play an essential part in this object. Is…
KiL
  • 1,500
  • 1
  • 14
  • 16
71
votes
9 answers

"not well-formed" error in Firefox when loading JSON file with XMLHttpRequest

I'm getting a "not well-formed" error in the error console of Firefox 3.0.7 when the JavaScript on my page loads a text file containing an object in JavaScript Object Notation format. If the file contains nothing but the JSON object, it produces the…
A. Levy
  • 29,056
  • 6
  • 39
  • 56
69
votes
6 answers

How to set iframe content of a react component

I am trying to set the content of an iframe in a React component but I am not able to do it. I have a component that contains a function which has to be called when the iframe finishes loading. In that function I am setting the content but it…
user3807940
  • 841
  • 2
  • 8
  • 16
69
votes
3 answers

How to add header data in XMLHttpRequest when using formdata?

I'm trying to implement a file upload API, given here : Mediafire file Upload I am successfully able to upload the Post data & Get data, but have no clue how to send the x-filename attribute, which is meant to be Header data as given in API…
67
votes
5 answers

Suppress Chrome 'Failed to load resource' messages in console

I'm writing a script that uses an XMLHttpRequest to search for a file defined by a relative path, by attempting to resolve that relative path against other same domain absolute paths that the script is aware of, then attempting to load the file from…
67
votes
3 answers

What is the boundary parameter in an HTTP multi-part (POST) Request?

I am trying to develop a sidebar gadget that automates the process of checking a web page for the evolution of my transfer quota. I am almost at it but there is one last step I need to get it working: Sending an HttpRequest with the correct POST…
m6a-uds
  • 935
  • 2
  • 8
  • 12
67
votes
2 answers

When loading external data, console says: XHR finished loading

Is there a way to hide the "XHR finished loading" messages in the console?
Kriem
  • 8,666
  • 16
  • 72
  • 120
64
votes
3 answers

XMLHttpRequest (Ajax) Error

I'm using XMLHttpRequest in JavaScript. However, it gives me an error, and I don't know what my problem is. I have to parse an XML file and assign its contents to the webpage - here's my code: