Questions tagged [xmlhttprequest-level2]

XMLHttpRequest Level 2 defines various new methods over XMLHttRequest level 1, such as the FormData object and new response types.

XMLHttpRequest level 2 adds new functionality over level 1, including:

See also

67 questions
224
votes
10 answers

Why does my http://localhost CORS origin not work?

I am stuck with this CORS problem, even though I set the server (nginx/node.js) with the appropriate headers. I can see in Chrome Network pane -> Response Headers: Access-Control-Allow-Origin:http://localhost which should do the trick. Here's the…
whadar
  • 3,209
  • 4
  • 17
  • 19
18
votes
1 answer

ArrayBuffer vs Blob and XHR2

XHR2 differences states The ability to transfer ArrayBuffer, Blob, File and FormData objects. What are the differences between ArrayBuffer and Blob ? Why should I care about being able to send them over XHR2 ? (I can understand value of File and…
Raynos
  • 156,883
  • 55
  • 337
  • 385
14
votes
2 answers

Chrome extension: how to pass ArrayBuffer or Blob from content script to the background without losing its type?

I have this content script that downloads some binary data using XHR, which is sent later to the background script: var self = this; var xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { …
14
votes
2 answers

CORS request is preflighted, but it seems like it should not be

The following cross-origin POST request, with a content-type of multipart/form-data and only simple headers is preflighted. According to the W3C spec, unless I am reading it wrong, it should not be preflighted. I've confirmed this happens in…
Ray Nicholus
  • 18,424
  • 13
  • 56
  • 80
11
votes
1 answer

XMLHttpRequest.addEventListener vs XMLHttpRequest.upload.addEventListener

What is the difference between the this code block: var xhr = new XMLHttpRequest(); xhr.upload.addEventListener("progress", uploadProgress, false); xhr.addEventListener("load", uploadComplete, false); xhr.addEventListener("error", uploadFailed,…
DMac the Destroyer
  • 4,770
  • 5
  • 29
  • 54
9
votes
1 answer

xhr.upload.onprogress doesn't work

Everything in the following code will work, except it will never fire the xhr.upload.onprogress event. $(function(){ var xhr; $("#submit").click(function(){ var formData = new FormData(); formData.append("myFile",…
user1534664
  • 2,868
  • 8
  • 32
  • 61
9
votes
1 answer

Uploading a file with XMLHttprequest - Missing boundary in multipart/form-data

I'm uploading a file with XMLHttprequest. Here is the JS function, that uploads a file: var upload = function(file) { // Create form data var formData = new FormData(); formData.append('file', file); var xhr = new…
Tamás Pap
  • 16,112
  • 13
  • 65
  • 94
8
votes
2 answers

Is it possible to set accept-charset for new FormData (XHR2) object or workaround

Here is example code (http://jsfiddle.net/epsSZ/1/): HTML:
Dfr
  • 3,915
  • 9
  • 38
  • 54
7
votes
1 answer

Unable to post to a new action method via .Ajax right after a successful XMLHttpRequest in IE 10

I am adding a new feature in my app which lets users to complete a process in steps. Step1 select dropdown value hit next button and step 2 (ajax request loads and renders a partial view, rendering a tree view) hit next button step 3 (upload a file…
tam tam
  • 1,765
  • 1
  • 18
  • 42
7
votes
3 answers

iOS 6 (iPhone/iPad) Image Upload "Request Body Stream Exhausted" with NTLM/Windows Authentication

I am working on trying to get iOS 6 to use XMLHttpRequest POSTs to upload images. This works on desktop and Android web browsers, but with iOS 6 I am getting an error on the page being posted to: "Request Body Stream Exhausted". (Using iOS…
5
votes
1 answer

XMLHttpRequest 2 download progress event only firing once

I'm trying to get the progress of an ajax request via the following code: var xhr = new XMLHttpRequest(); xhr.addEventListener('progress', function(event) { console.log(event.loaded / event.total); }, false); xhr.addEventListener('load',…
DADU
  • 5,236
  • 5
  • 38
  • 61
5
votes
2 answers

JS ProgressEvent is only fired when finished

I am having some problems getting my upload progress bar to work properly. According to the XMLHttpRequest Level 2 specs, I attached event listeners for loadstart and progress like this: var xhr =…
Leo Selig
  • 992
  • 1
  • 15
  • 30
5
votes
1 answer

No XMLHttpRequest 2 progress in Android stock browser

I have a working file upload form that uses XMLHttpRequest 2 to upload files to Transloadit (a file processing service). The progress events get fired correctly in Firefox and Chrome, both for Desktop and for Android. But the Android (4.0) stock…
4
votes
0 answers

How can I cap the download speed of XHR2 in javascript

I have implemented a "downloader" using XMLHTTPRequest, which I use to download files and parts of files using javascript. For testing and maybe also for real-world scenarios, I would like to limit the bandwidth this downloader takes. One option I…
whadar
  • 3,209
  • 4
  • 17
  • 19
4
votes
1 answer

How do you handle an "Access to restricted URI denied" error in JavaScript when using XMLHttpRequest?

I have the following code: var req = new XMLHttpRequest(); req.onload = function(){ if (req.status === "200"){ doSomethingWithTheReceivedData(); } else { alert("Error msg"); } }; However when running index.html…
1
2 3 4 5