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
1 answer

Chaining jQuery promises/deferreds

I have a process where I have to send an ajax request to the server, but need to stop a scheduler before the ajax request begins, then restart the scheduler when the request is done. I have got this working using the following…
Appetere
  • 6,003
  • 7
  • 35
  • 46
0
votes
1 answer

Having multiple imageLoaded calls on 1 page and making sure each call is complete before progressing

I have 3 sections on my page that contain lots of images of various sizes, what I need to do is make sure each of these 3 sections images have completely loaded before I continue with applying any transitions etc like fading the sections in etc. I…
styler
  • 15,779
  • 23
  • 81
  • 135
0
votes
1 answer

How to know when asynchronous functions finish

I have a function that calls an asynchronous function multiple times in a loop. function myFunc() { var things = [1, 2, 3, 4, 5]; $.each(things, asyncFunc); alert('Things ' + things.join() + ' have all been processed.'); } function…
Chris Watts
  • 6,197
  • 7
  • 49
  • 98
0
votes
1 answer

Asynchronous Geolocation API and jQuery Deferred Objects

I am trying to use the Javascript Geolocation API to get the user's longitude and latitude. I would like to be able to get that information by calling the getCoords() function but am having a problem. This code: function getCoords() { var…
0
votes
4 answers

Jquery Ajax Promise does not work

I'm making a app and I'm unable to fire a promise, I breaked the code to the a simple example that still does not work, I'm using EasyPHP... ajaxDialog = function( destiny ) { // Promise to let me know when complete return $.ajax({ …
Bruno Teixeira
  • 565
  • 4
  • 11
  • 25
0
votes
1 answer

how to return a deferred object on a phonegap class using jquery?

ill start with an example: jQuery.when(setLocation()).then(function(e) { console.log(e); }); function setLocation(){ return navigator.geolocation.getCurrentPosition(setLcationSuccess, onGeoError); } function setLcationSuccess(position) { …
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
0
votes
3 answers

Trying to understand $.get, $.when and $.then

I'm trying to understand $.when(...).then(...).done(...). This is just tests. Html:

javascript: var p = $('#phrase'); function displayResult(o){ console.log(o); p.append(o + '…
Johnny5
  • 6,664
  • 3
  • 45
  • 78
0
votes
1 answer

how to set a deferred on ajax with jquery?

let me start with some code: function sendAjax(data, type) { $.ajax({ type : "GET", dataType : "jsonp", url : rest + type, data : data, }); } $.when(sendAjax(someData, 'url')).then(function(data){ …
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
0
votes
1 answer

How make $.ajaxSetup rely on a backbone.js model initialized later

I have the following backbone.js application initialization process : var app = { init: function(arg) { $.when(app.loadStaticFiles('any_file_to_load_before')) .done(function(args) { app.models.current_user = app.Models.User(); …
Meta Lambda
  • 703
  • 1
  • 7
  • 13
0
votes
1 answer

Skip ajax (or any other procedure) from another event (or function)

So problem is that there, we have a 2 tabs, 1st tabs loads a content by ajax1, and 2d tab loads a content by ajax2. So use case: Click 1st tab, loading ajax content. Did a fast click, do not wait while ajax finished. The tab2 content (ajax2 finished…
Dmitry
  • 816
  • 1
  • 9
  • 17
0
votes
1 answer

how do I properly pass results from jQuery $.ajax() through several functions?

I'd like to pass the result of my ajax function to another one (sort of like "bubbling up an event"). I really need to keep the ajax wrapper function as-is, i.e. generic, so I'm looking for a solution that does not touch…
tim
  • 3,823
  • 5
  • 34
  • 39
0
votes
3 answers

Variable scope with deferred / ajax in jQuery

I'm using pretty standard setup I think. A click on element to call a function that handles an ajax request. My limited understanding of variable scope and callbacks when using asynchronous anything and trying to figure out jQuery deferreds is…
tim
  • 3,823
  • 5
  • 34
  • 39
0
votes
1 answer

jQuery deferred always method

I need to do something when an ajax request is completed, irrespective of it's failure or success. I am using jQuery deferred objects "always" method for this. My question is inside "always" method how do I determine if it's called because service…
sublime
  • 4,013
  • 9
  • 53
  • 92
0
votes
2 answers

More complex Deferred/promise usage and chains just aren't clicking. Would love some clarification

I've found that the documentation for a variety of Deferred/promise libraries often covers really simple use cases, such as chaining 1 or 2 functions/methods and resulting in a resolved or rejected success or error. However, when it comes to more…
J. Ky Marsh
  • 2,465
  • 3
  • 26
  • 32
0
votes
1 answer

jquery deferred and css3 transitions

For an Ajax call I have some transitions for different elements that have to be called in a specific order. When reading about jQuery Deferred I thought this is what I was looking for, but I can't seem to get it to work. I made a simple jsfiddle to…
paul_ngc
  • 111
  • 1
  • 10