Message from JavaScript discussions

February 2017

— I think I might be seeing... a hoisting issue


I think by the time the object gets to the traversal function, it is empty, but after it gets logged the properties are added

— I think is the only way you're getting that issue.

— Yeah, it is right in there with 2 ajax and promises... whats happening is the actions are getting dispatched with empty parameters before the ajax promises resolve

Message permanent page

— Aha, I shall use Promise.all()

— Returns a new promise that only resolves when a list of promises given to it resolve

— So I can run the ajax, generate promises for the multiple requests, give them to Promise.all() and run my endgame code in then() on the final promise

Message permanent page

— Hii guys. I like to large video uploading . But iam not uploading videos . Can any help me out by using jquery

Thanks in advance

Message permanent page

— For large file upload via XHR is recomendable to use chunked file upload. Here is a JQuery plugin that supports that:

Message permanent page

— +1

— Tiny baby ajax

function ajax (url = "/", resType = 'text') {
return new Promise (function (resolve, reject) {
var req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status >= 400 && req.status < 600) {
reject("HTTP Error " + req.status + ": " + req.statusText);
} else if (req.status >= 200 && req.status < 400) {
};"GET", url);
req.responseType = resType;
req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

Message permanent page


ajax("/url", "json").then(function (response) {