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

68 questions
307
votes
11 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
  • 4,181
  • 4
  • 19
  • 21
19
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
  • 166,823
  • 56
  • 351
  • 396
16
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
  • 19,538
  • 14
  • 59
  • 82
13
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
  • 17,777
  • 15
  • 70
  • 102
12
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
  • 4,075
  • 10
  • 40
  • 63
12
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
  • 3,258
  • 8
  • 40
  • 66
12
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
  • 5,240
  • 6
  • 36
  • 56
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,870
  • 2
  • 21
  • 46
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
  • 6,482
  • 7
  • 42
  • 64
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
  • 1,062
  • 1
  • 16
  • 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
  • 4,181
  • 4
  • 19
  • 21
4
votes
4 answers

How to compare two blobs in JavaScript?

I load two blob files in JavaScript using the code below. I want to compare them to see if they are precisely the same. (blob1 === blob2) is returning false, even though the reported size of each blob is 574 bytes. What am I doing wrong? …
Duke Dougal
  • 24,359
  • 31
  • 91
  • 123
1
2 3 4 5