javascript - dojo xhrPost progress (callback) event listener? -


in dojo api documentation can find callbacks load , error missing callback progress.

load: function(data) {     dojo.byid("response").innerhtml = "form posted."; }, error: function(error) {     dojo.byid("response").innerhtml = "error..."; } 

the xmlhttprequest api provides possibility, register event listeners progress event:

var oreq = new xmlhttprequest();  oreq.addeventlistener("progress", updateprogress, false);  oreq.addeventlistener("load", transfercomplete, false);  oreq.addeventlistener("error", transferfailed, false);  oreq.addeventlistener("abort", transfercanceled, false);  oreq.open();  // progress on transfers server client (downloads) function updateprogress (oevent) {...} 

has dojo mechanism, similar xmlhttprequest api?

the new dojo/request module supports progress events. automatically call new dojo/xhr module on browser platforms.

don't confuse these api's old, deprecated, counterparts. there key differences in way modules included , called:

  1. different files must included in different manner (amd instead of require(dojo.*))
  2. the methods must called differently , return different types. new request api uses promises instead of callbacks.

use following guides convert code new api (may require updating more recent version of dojo):


update: if must use dojo 1.6...

you have 2 options:

  1. use more modern dojo next dojo 1.6 part needs progress event. new amd architecture means new library isolated require() callback's block. amd architecture means can load minimal parts of modern dojo required new xhr.
  2. backport progress event feature dojo 1.6. can add callback , code doesn't seem complex. (don't forget account differences because you're not using promises.)

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -