Questions tagged [jquery-deferred]

jQuery's deferred (also known as promises and futures) can be used to manage callback queues

Filter by
Sorted by
Tagged with
1 vote
1 answer
49 views

Call multiple ajax and take only success result using jquery

I have 1 html (2cols, 6rows) and 12 ajaxs. Each ajax's result will be binding to its own (regardless of success or failure). Ajax will return 200 or 403. don't know at this time. ※IMPORTANT※ All ...
김동현's user avatar
0 votes
1 answer
41 views

Chaining jQuery.Deferred

I have got two JS functions, both return jQuery's promise. Let's say they are: getServerTimestamp() and, say, doSomething(). getServerTimestamp(), on its first call, basically gets the current time ...
user2526586's user avatar
-1 votes
1 answer
73 views

Issue with Native promise resolve outside the function

I am trying to refactor jQuery promises with native promise for the below codes. public functionA(){ const dArray = Array<JQueryDeferred<{a:string}>>=[]; //other lines of logic ...
Itsme's user avatar
  • 65
0 votes
1 answer
66 views

caching using jquery deferred versus promise

I currently have some code using jQuery Deferred and ajax to call remote api and get the data and put in localStorage and get data from localStorage. This code seems buggy the first time it runs (i.e. ...
AJSwift's user avatar
  • 709
0 votes
1 answer
96 views

How to properly use jQuery Deferred inside of a loop

I'm trrying to call a function that loops through a dataset and updates values in that dataset from data that comes from an asynchronous function. I obviously need to know when that function completes ...
TheCarver's user avatar
  • 19.4k
0 votes
0 answers
222 views

Uncaught TypeError: Cannot read properties of undefined (reading 'deferred')

I am trying to make a panel in wordpress, with wp.customize wordpress object but i got this error. Uncaught TypeError: Cannot read properties of undefined (reading 'deferred') (function ($, api) { ...
amirhosein karimi's user avatar
0 votes
1 answer
132 views

Using Typescript promise instead of jQuery deferred

I am having the below lines of code which is using JQueryDeferred object from the type definition class jquery.d.ts. Trying to replace jQuery deferred to typescript promise. Existing JQueryDeferred ...
Itsme's user avatar
  • 65
0 votes
1 answer
99 views

How to extract a value from a promise when called synchronously using Javascript `await`?

I'm working on a project that uses a custom user prompt using jQuery / jQuery UI: function dialog_confirm(dialog_body, dialog_title = 'Confirm') { var def = $.Deferred(); $('<div></div&...
osullic's user avatar
  • 553
0 votes
2 answers
123 views

How do I delete a callback deferred.progress?

How do I delete a previously assigned handler? var deferred = $.Deferred(); var callback = function(n) { console.log('Test ' +n); } deferred.progress(callback); deferred.notify(1); $(...
Надим Закиров's user avatar
0 votes
1 answer
135 views

Ajax request made but position of value in returned response as array keeps changing. how do I fix this

I have a script which sends an array of numbers via Ajax to a web server. The values are used to query a database and then the corresponding values of those numbers In the table are sent back which I ...
4 Figure Creatives's user avatar
0 votes
0 answers
23 views

How do I use $.when() instead of await in the following function?

I have the following 2 functions: $(document).on(`dragover drop change`, `.fileUpload`, async function(e) { e.stopPropagation(); e.preventDefault(); const thisEl = $(this); if (thisEl....
Chris's user avatar
  • 680
0 votes
0 answers
40 views

Chaining jQuery promises

I wish to call dealCardSelectableAI(), have it chooseCards(), then use the output to set an observable system.star.cardList(), then call setCardName(). Once all this is done I want saveGame() to ...
Quitch's user avatar
  • 89
0 votes
1 answer
79 views

Function returning before jQuery promise within promise is resolved

I have a function which calls dealCardSelectableAI(), which sets up a number of jQuery deferred promises. The function setCardName() is then called from within it. Once both functions complete their ...
Quitch's user avatar
  • 89
0 votes
0 answers
21 views

Is $.when() or $.when.apply() the correct call for getting a promise out of a forEach?

I have a function processing an array, calling a function for each entry within the array with a Promise returned, and then finally returning that it's done. var dealCardSelectableAI = function () { ...
Quitch's user avatar
  • 89
0 votes
2 answers
39 views

What is the difference in jQuery between returning deferred and deferred.promise()?

I'm working in an ES5 environment using jQuery. I have some code as follows: var saveGame = function (gameState, saveStars) { var deferred = $.Deferred(); var starsSaved = saveStars ? false : true;...
Quitch's user avatar
  • 89
0 votes
1 answer
71 views

Deferred jquery ajax

I've looked through all the issues on this, I think. I have a function which uses jquery to update a record via ajax. I need to change it to do them and wait for each one to finish. I've been reading ...
Chris's user avatar
  • 558
0 votes
1 answer
232 views

In jQuery, how to deal with parallel script loading?

I am stuck with this in an app development and don't know what to try. I have the following function: // Function to load Scripts on the fly $.loadScript = function(url, arg1, arg2) { var cache = ...
Fran Díaz's user avatar
1 vote
2 answers
95 views

jQuery Confirm3 $.confirm nor returning boolean neither expected result

I have 2 functions related to each other .. _confirm and _process. _confirm is responsible for returning true/false values to _process and based on response _process function will act and process the ...
Muzammil Hussain's user avatar
1 vote
1 answer
1k views

Uncaught TypeError: $(...).select2 is not a function in CodeIgniter

I am new to CodeIgniter and am currently stuck on a task in which I need to use multi select dropdown to display categories while adding a new product but when I run my code it shows the following ...
ANewcoder's user avatar
1 vote
1 answer
77 views

Arguments in whenAllDone promise/deferred javascript helper not working when I wrap existing code into a Deferred

I'm trying to implement the following in TypeScript: https://stackoverflow.com/a/15094263/166231 UPDATE 2 - The problem with original answer is that it doesn't support a single deferred. I modified ...
Terry's user avatar
  • 2,168
2 votes
1 answer
47 views

How to ensure functions in .then() complete before proceeding?

Below is the usage of $.when().then(). $.when(setLineDet(rptId, rptLn)).then(function(data) { console.log("done setting line details"); setHeaderDet(rptId); })....
Reshinaath's user avatar
2 votes
1 answer
441 views

Vuex action returning jQuery promise doesn't work, .fail is not a function

I have a vuex action like this myAction() { const deferred = $.Deferred(); setTimeout(() => deferred.resolve(), 3000); return deferred.promise(); } in my vue component myMethod() { ...
coure2011's user avatar
  • 40.5k
1 vote
1 answer
103 views

Is it possible to queue in succesion an array of functions that return promises?

Have the next example: function exec() { var dfd = $.Deferred(); asyncStuff().then( function(res) { if(res) { dfd.resolve(true); } else ...
Leandro Gamarra's user avatar
2 votes
0 answers
107 views

Chaining Ajax calls fail after upgrading jQuery to 3.x

I'm working on a very old project with the following frameworks for unit testing: QUnit 1.14.0, Sinon 1.17.2, jQuery 1.12.4 This unit test works fine with jQuery 1.x and 2.x. But after upgrading to 3....
Gannys's user avatar
  • 33
-1 votes
1 answer
31 views

jQuery calling a Deferred function not working

Calling loadLevel1Categories from checkSessionCount and then do something to the all .alvl1 classes. I know the data is being returned as I can see it. It seems that the Defer isn't working. I've ...
Martin's user avatar
  • 240
1 vote
0 answers
99 views

Concurrent AJAX requests appear to delay each other

I have a form that queues up parallel ajax queries using essentially this pattern: var req1 = $.Deferred(); $.ajax("...", {type:'GET', data:form, /*...*/, success:function(){ req1.resolve(); ...
Alain's user avatar
  • 26.7k
0 votes
0 answers
106 views

How to make Ajax wait for a condition?

I have to show data for a number of clients. Unfortunately, the loading process for a group of clients is super slow. Then I've decided to load one by one and as soon as possible, in other words, when ...
O Pardal's user avatar
  • 647
1 vote
1 answer
172 views

How to enable (progress bar / loading icon) for a frozen screen?

I have a webapp that loads an csv file to view in the app. I tried loading a large file and it freezes the screen for some time, and then finally loads the csv file and displays the csv contents. I ...
mk117's user avatar
  • 753
0 votes
0 answers
1k views

Keep getting error: $.deferred is not a function

I've installed jquery and @types/jquery. I want to use jquery.Deferred() but when i try to use it I get error that "$.Deferred is not a function". import * as $ from "jquery"; u // ...
J.Doe's user avatar
  • 31
0 votes
2 answers
188 views

waiting for JS async func to complete before running some sync code

I have an async function getDataItem that returns a promise and passes data to another function preparePhysicianSchemaData which builds a global object physicianDetailsObj out of the passed data as ...
AJSwift's user avatar
  • 709
0 votes
1 answer
224 views

How to use promises in jquery?

I am pulling in multiple divs via multiple ajax calls. Before the first ajax call I want to display a loading spinner. Once all the divs (which will take an unknown time) have loaded I want to sort ...
happysailingdude's user avatar
0 votes
1 answer
171 views

Asynchronous / Deferred JavaScript issue

I am using this code at footer for Eliminate render-blocking resources <script async or defer src="/jquery.js"> /* custom code */ <script> $(document).ready(function(){ $('.menu-bar'...
Yogesh Saroya's user avatar
0 votes
1 answer
499 views

Show and then hide a Bootstrap Alert while JQuery runs?

When a user changes a dropdown on my page, I have some JQuery that does "stuff". I want to add the "show" class to my Bootstrap alert and then remove it when "stuff" is done. In my current attempt, I ...
Ryan Wilkins's user avatar
0 votes
2 answers
101 views

Wait for async calls inside a loop to finish

I know questions similar to this have been asked many times, but some are old and suggest deprecated solutions, some describe a solution but not in the context of a loop, and none of them directly ...
Merik's user avatar
  • 2,767
0 votes
1 answer
68 views

Loop print after function ends retrieve multiple data

I've create a web app to store the quotation requested from clients. A quotation can be multiple so when I print one quotation it's possible I've to print the connected quotation. To do that I'm ...
DellaeMme's user avatar
1 vote
2 answers
1k views

How to move the inline jQuery script of Ajax Gravity Form to the footer?

For adding defer to jquery link, I would like to move the inline jQuery script of Ajax Gravity Form to the footer. How can I do for this?
forevereffort's user avatar
-2 votes
2 answers
1k views

How to return promise from "ajax success"?

I need to write function which prepare me a HTML to inuput into my site, I tried like this function prepareHTML(valId){ $.ajax({ type: "POST", url: "SOAPulr_getData", data: {operationId:...
ssnake's user avatar
  • 365
0 votes
0 answers
60 views

Effectively using $.when.apply(...) on custom promises

I'm using $.when.apply(methodArray[...]) in order to return the method callback arguments in my overall "done" callback. This works fine when the methods are $.ajax(options) calls, but sometimes the ...
Everett McCoy's user avatar
0 votes
0 answers
83 views

How to get data from one api call to another using deferred object?

I have to make two api calls - tenants and users. The tenant api returns all the existing tenants details and the user api will return all the users in a particular tenant. I need to map the tenant ...
Sona's user avatar
  • 35
0 votes
0 answers
48 views

jQuery - deferred and promise

I'm a bit new to deferred and promises and I got code as follows: function validateAndSave(){ var def = $.Deferred(); validateAPIcall.done(function (errorCount) { if(errorCount &...
James's user avatar
  • 87
0 votes
1 answer
29 views

Attach deferred handlers to nested AJAX call outside function

I'm trying to create an AJAX method extension called getApi that will automatically add my bearer token to the request header. I have a deferred function called getToken() that returns either the ...
Codemunkie's user avatar
0 votes
1 answer
88 views

How can I achieve Promise.all().then() behavior with jQuery.when().done() if I have an unknown number of requests? [duplicate]

I have a little code segment like this: var requestArray = []; thingArray.forEach(function (thing) { var uri = "https://server/_api/endpoint/things(" + thing.Id + ")"; requestArray.push($....
Dylan Cristy's user avatar
0 votes
0 answers
70 views

Is the following how jQuery promise chaining is written compared to how ES6 promise chaining is written?

Is the following jQuery code equivalent to how it is done in ES6's way, or should the jQuery way be written differently? // ES6: new Promise((resolve, reject) => { console.log("start"); ...
nonopolarity's user avatar
1 vote
0 answers
35 views

How can I make many AJAX requests, then call a function when they have all completed? [duplicate]

I have the following function that returns a jQuery deferred object: function performAjaxRequest(arg1, arg2, arg3) { return $.ajax({ url: someurl, type: "POST", data: { ...
ic3man7019's user avatar
0 votes
1 answer
100 views

jQuery Deferred - How to wait or delay for .animate function to finish before .done() is executed?

I have a series of deferred actions that take place as part of a $.when() .done() $.when( $activeHighlight.removeClass('active'), $nextHighlight.addClass('active'), ...
Spectator6's user avatar
1 vote
1 answer
4k views

Bootstrap Selectpicker not refreshing

When a user clicks the edit icon the contents of a selectpicker are updated then refreshed. Then the selectpicker's value is updated, then refreshed again, but for some reason it is not updating with ...
Beengie's user avatar
  • 1,588
1 vote
1 answer
126 views

How to use jquery .defer or .done when validating a form (with unobtrusive) prior to submitting it or preventing submission

From other examples I've tried using defer and promise (first time), but it's not working. I am using unobtrusive validation on my form. There is a submit, then I trap that submit event where I get ...
Neal Rogers's user avatar
0 votes
1 answer
68 views

Ajax call return function instead of data

I make a request with jquery $ajax call, but it returns the callback function itself, instead of the correct data response and showing the message "ReferenceError: recapCB is not defined"; var ...
Lorenzo Catalano's user avatar
1 vote
0 answers
184 views

How to make sure that the following recursive function is resolved or completed and then do some operations?

i made a recursive function which will get the file details from a share point document library recursively but unable to know whether the recursive function is resolved or completed //function ...
srinath's user avatar
  • 43
4 votes
2 answers
143 views

Wait until function finish to run another function

I've encountered a problem that's driving me crazy for like 10 days now... Basically i have a function that fire (the handleText) and I want to wait the end of that function before running a second ...
kkqe's user avatar
  • 43

1
2 3 4 5
23