Questions tagged [jquery-deferred]
jQuery's deferred (also known as promises and futures) can be used to manage callback queues
1,138
questions
0
votes
1
answer
25
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
21
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
32
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
37
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
15
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
31
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
32
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
84
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
54
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
558
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
47
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
43
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
293
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
60
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
73
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
24
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
57
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
47
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
90
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
561
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
143
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
77
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
85
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
129
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
63
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
54
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
777
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
46
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
56
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
39
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
27
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
33
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
52
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
60
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
3k
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
59
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
64
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
138
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
136
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 ...
0
votes
1
answer
4k
views
Showing "waiting" modal _before_ my lengthy table sort starts (and disappear afterwards)
I just want to do three things in order.
My table has thousands of rows and takes a while to sort. I would like my "waiting" modal to display during the sort, but the page waits for the sorting to ...
0
votes
0
answers
270
views
Wishlist ajax request with Deferred Object
I am using a function with an AJAX request to count items in my wishlist ( I am using a YITH wishlist plugin) everything is working fine but it's to slow. Each time I click on an item to add it to ...
1
vote
1
answer
2k
views
How to defer parsing the jQuery code file?
I need to defer this code in my Shopify theme.liquid
{{ 'jquery.min.js' | asset_url | script_tag | remove: ' type="text/javascript"' }}
Can anyone help how to do this? It's in the <head>.
I'...
0
votes
0
answers
76
views
Usage of jQuery deferreds does not defer execution of a function
I'm currently stuck on the frontend of a plugin I am writing. I am trying to defer the execution of a filter function for HTML table row elements (hide(), show()) and markers on a leaflet map until ...
0
votes
2
answers
126
views
jquery .done() still runs before deferred.resolve()
I have read several questions here on this topic and I still can't see what is wrong. I have two functions, one initializes an image from a file and reads its dimensions, setting them to object's ...
0
votes
0
answers
165
views
Object doesn't support property or method 'Deferred'
I have implemented a javascript confirmation dialog.
The dialog will open onClientClick event:
<asp:Button ID="btnIssuerRemove" runat="server" class="ui-button ui-widget ui-state-default ui-...
0
votes
1
answer
112
views
How to overwrite/cancel previous promise called one by one?
I have jQuery code that respond to user keyboard press and I'm checking if element is in view. The plugin return promise if user press the key very fast or hold it (right now it's too fast for my code)...
-1
votes
1
answer
45
views
How do I use a deferred in a for loop
I am trying to pull back several sets of statistical data and display progress messages once each set of data has been loaded onto the DOM.
I am trying to use multiple deferreds along with the ...
0
votes
1
answer
21
views
Chaining dependent jQuery deferred with progress, fail and then
I'm somewhat new to js promises and working on a legacy system using jQuery 1.7.1
while trying to clean up some callbacks mess, I seems to be creating a new one.
Thanks in advance for your help!
...