Questions tagged [jquery-deferred]
jQuery's deferred (also known as promises and futures) can be used to manage callback queues
1,147
questions
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 ...
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 ...
-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
...
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. ...
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 ...
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) {
...
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 ...
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&...
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);
$(...
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 ...
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....
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 ...
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 ...
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 () {
...
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;...
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 ...
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 = ...
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 ...
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 ...
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 ...
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);
})....
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() {
...
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
...
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....
-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 ...
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(); ...
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 ...
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 ...
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
// ...
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 ...
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 ...
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'...
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 ...
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 ...
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 ...
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?
-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:...
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 ...
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 ...
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 &...
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 ...
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($....
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");
...
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: { ...
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'),
...
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 ...
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 ...
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 ...
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 ...
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 ...