Questions tagged [jquery-deferred]

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

jQuery.Deferred(), introduced in version 1.5, is a chainable utility object that can register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.

1147 questions
-1
votes
1 answer

jQuery deferred.fail() only executes once

Below jQuery's deferred fail() only executes once, why? var dfd = $.Deferred(); $('button').on('click', function(){ if(typeof lorem === 'undefined') { return dfd.reject(); } }); dfd.fail(function(){ alert('Variable lorem is…
bart
  • 14,958
  • 21
  • 75
  • 105
-1
votes
1 answer

Jquery array of Deferred for image preloader

I'm trying to call a function after all images in predefined array are loaded. Trying smth like this for (var i = 0; i < length; i++) { d = $.Deferred(); promises.push(p); img = new Image(); img.onload…
Kotanet
  • 573
  • 1
  • 8
  • 26
-1
votes
2 answers

Multiple Console Errors Logged for JavaScript/jQuery Code

Hi I am having a series of issues with my JavaScript/jQuery code! And even though I browsed through a list of similar questions, I can't find any answers that fits my problem. These are the issues logged to the Google Chrome developer…
-1
votes
1 answer

Jquery Defer & Each Loop

I'm a bit new to JSON and Deferrers, so apologies it the answer is obvious. I am working with the pokeapi.co and I am trying to pull out details of various pokemon using getJSON. I created a function which takes an array of URLs, runs a getJSON…
tcherokee
  • 87
  • 13
-1
votes
1 answer

How to Determine if There Are Any Un-Resolved Promises, Deferreds or Callbacks using jQuery?

Is there way to determine if there are any unsolved promises, deferreds or callbacks in jQuery? We have a large single-page JavaScript application that is hanging on $(document).ready(). For debugging purposes we would like to see if we missed…
A2MetalCore
  • 1,621
  • 4
  • 25
  • 49
-1
votes
2 answers

Deferred chains in jquery

I need to make 3 requests in chain. So for this I use jquery deffered. Request 1 -> on done if response contains expected result then Request 2 else return empty array/null -> on done if response contains expected result then Request 3 else return…
demo
  • 6,038
  • 19
  • 75
  • 149
-1
votes
1 answer

Gecoding addresses through Google maps api and deferring the results

I am using Google's maps API to geocode two addresses. I defer the returned results and use a $.when().then() method to execute my logic once I get the coordinates for the string addresses. The problem is the API always returns the result as…
-1
votes
2 answers

jQuery deferred - done not working

i am trying to learn jQuery deferred and implement it in my code. function function1() { $deferred = $.Deferred(); setTimeout(function() { alert("Hello"); }, 3000); return $deferred.promise(); } function function2() { …
Lijin Durairaj
  • 4,910
  • 15
  • 52
  • 85
-1
votes
3 answers

jQuery deferred object chaining failing

Why does this code not work? It should wait for step 1 to load before loading step 2.Currently, step 2 fires first. I am using mockjax to simulate the Ajax calls. $.mockjax({ url: "/step1", responseTime: [3000, 4000], responseText: { …
AnotherMike
  • 2,633
  • 2
  • 16
  • 15
-1
votes
1 answer

jQuery deferred array not triggering .done() as expected

I'm having some trouble with jQuery deferreds. Here's my code: function makeAjaxCalls(purge){ var deferreds = []; // delete the documents _.each(purge, function(element, index, list){ console.log('purging '+element.model+'…
David Williamson
  • 387
  • 1
  • 5
  • 18
-1
votes
3 answers

Is there a way to force a Deferred() to execute synchronously?

Somewhere else in code there's this: function getMyDeferred() { var deferred = $.Deferred(); $.ajax(url, { success: function(data) { deferred.resolve(data); } }); return deferred; } In my code, I'm…
soapergem
  • 9,263
  • 18
  • 96
  • 152
-1
votes
2 answers

$.Deferred.then() function doesn't allow unknown number of time to call the function dynamically?

I came upon this script from Google search at jQuery Deferred and Promise for sequential execution of synchronous and asynchronous funcitons . This may solve my issue on executing the script in sequiental order. But the problem I have with then()…
fletchsod
  • 3,560
  • 7
  • 39
  • 65
-1
votes
2 answers

Multiple jQuery deferred objects in a when

So, if I have multiple Ajax calls, is it possible for each of them to have done callback and be in a when then??
Manny Fleurmond
  • 362
  • 1
  • 6
  • 18
-1
votes
2 answers

best way to defer a function after another one in javascript

I tend to run into this problem quite often, and my solutions never really work the way i wanted to. Basically, I want one function to wait till the one before is completely finished running. For example, I have a gps locating function, and i want…
z.a.
  • 2,549
  • 3
  • 12
  • 16
-1
votes
2 answers

jquery deferred setTimeout loop

I have an array of functions to iterate with setTimeout function to give non-blocking effects, but any or all function can have order flag, which means this is to be executed only after previous functions have been executed. Someone suggested me to…
Avneesh Raghav
  • 319
  • 2
  • 11
1 2 3
76
77