E
E
Extramezz2015-10-31 10:36:15
JavaScript
Extramezz, 2015-10-31 10:36:15

What is the problem with Ajax onprogress?

JS code:

$.ajaxSetup({
  xhr: function(){
    var xhr = new XMLHttpRequest();
    xhr.addEventListener("progress", function(data){
                     console.log(data.loaded, data.total);
                });
    return xhr;
  }
});

$.ajax({
  url : "file.txt",
  success : function(){ alert("!") }
});


What is in the file file.txt ? - It just contains text for the test, the file weighs 20mb.

Running the code above, I get in the console only something like 20мб, 20мб. Why does onprogress work only once, and even then, at the very end?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Scribblex, 2015-10-31
@Scribblex

jsfiddle.net/r86gM/9 is a good example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question