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
0
votes
2 answers

Geocoding using Google Maps API v3 - Linking the original request to the response

I have a list of schools that I want to plot on a Google Map. I'm using Google's Geocoding Service to lookup the lng/lat for a given postcode, upon successfully retrieving this information I want to drop a marker, together with adding the…
0
votes
1 answer

Not using jQuery promise objects appropriately. Not sure why

I'm trying to use this in coffeescript : $(this).hide().each (index) -> $(this).delay(index * 100).fadeIn 1000, arguments.callee $(this).promise().done -> console.log 'hey trip' The same thing in au naturale JS …
Trip
  • 26,756
  • 46
  • 158
  • 277
0
votes
1 answer

deferring $.ajax requests

I have to make N ajax requests. Each $.ajax call returns a Deferred, but also immediately performs the ajax request. What i want to do is get the Deferreds for all N requests, but only have them performed gradually (say through a setInterval loop).…
v_y
  • 225
  • 2
  • 9
0
votes
1 answer

jQuery mobile event.preventDefault()

i've searched around and tried some solutions, but i can't get event.preventDefault() working on a simple page transition bind: $("#trainingmodus").bind('pagebeforeshow', function(event, data) { event.preventDefault(); console.log("trainingmodus…
Michahell
  • 4,905
  • 5
  • 29
  • 45
0
votes
1 answer

How to implement a preloader with jQuery deferred objects

I'm using jQuery deferred objects so I can pull data from multiple sources , however not sure how best to code in a loading message that displays whilst everything is being resolved and then hides when everything is resolved OR rejected CURRENT…
experimenter
  • 768
  • 1
  • 9
  • 30
0
votes
1 answer

Chaining ajax deferreds between function calls

I'm having a bit of trouble with jQuery Deferred. I'm using a jQuery ajax call inside a function wrapper, and I'm attempting to chain two success callbacks one after the other, in order of scope. However, both success callbacks are executing…
user677526
0
votes
1 answer

Can Deferred.pipe() prevent call of both subsequent .done and .fail?

I have two handlers: onSuccess and onFailure, but I want sometimes (when the server decides so), to prevent either of them from running. I know I can return some 'ignore' from the .pipe() and to test for it within the .done() and .fail() handlers,…
Tar
  • 8,529
  • 9
  • 56
  • 127
0
votes
1 answer

jQuery: using deferred object inside success/error (ajaxSetup option)

I want to set up global behavior for all AJAX requests, and sometimes I need to interrupt queue like this $.ajaxSetup({ success: function(data, textStatus, jqXHR) { if ( data.error ) { jqXHR.reject(); } } }); // later $.ajax({ some:…
bor
  • 181
  • 1
  • 6
0
votes
1 answer

jQuery Deferred, trouble getting a value in a chain

The result of buildMyUrl is always undefined in the calling function. I'm not sure what I'm doing wrong chaining these functions: var buildMyUrl = function (callback) { var param; var addParams = function (domainUrl) { …
Jon Wells
  • 4,191
  • 9
  • 40
  • 69
0
votes
2 answers

waiting for animations on mutiple elements with $.deferred

I have a code like this: for(i=0;i
Taha Paksu
  • 15,371
  • 2
  • 44
  • 78
0
votes
1 answer

Calling jQuery $.Deferred .state() method is launching back done() method

I was doing some testing on an app, and I realized that calling .state() on a Deferred object seem to launch .done() callback again and again. I produce a reduced test case here http://jsfiddle.net/vaxilart/ajeGm/ I was wondering if this is a normal…
Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134
0
votes
1 answer

jQuery validate and deferred objects

I have a form that is using the jQuery validate functionality, with some custom functions validating the values with ajax posts. My problem is when I submit the form, I have the submitHandler do ajax post to check if the field is valid by checking…
SynackSA
  • 855
  • 1
  • 12
  • 35
0
votes
2 answers

How to return promise that will resolve with the result of several functions?

I'm developing a jQuery plugin, which pretends to translate elements on the page, automatically depending on the user's browser language. Translations will be stored in .json files. When you call the plugin, you pass a package name (or an Array of…
Antonio Laguna
  • 8,973
  • 7
  • 36
  • 72
-1
votes
1 answer

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 tested by putting a setTimeout just after the…
Martin
  • 240
  • 4
  • 13
-1
votes
1 answer

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 setTimeout function to manage the response to the…
Lee A
  • 45
  • 1
  • 9