Questions tagged [.when]

.when is a jQuery function for executing a function when the included AJAX request(s) have been completed. It usually precedes .then.

.when is a jQuery function for executing a function when the included AJAX request(s) have been completed. It usually precedes .then. An example of a usage would be:

$.when($.post(foo1), $.post(foo2)).then(function (a, b) {
  /*
    execute this when requests to foo1 and foo2 have been made. a[0] and b[0] contain
    the results returned by the two pages foo1 and foo2.
  */
});

Documentation

174 questions
0
votes
3 answers

Jquery When and Deferred object, broken function flow

I am using $.when and .done to make sure that the close window happens after the data is saved. But, this doesn't seem to work as expected. The workflow is that, user clicks on a button "Save and Close", which should save the data first, trigger…
Sri Reddy
  • 6,832
  • 20
  • 70
  • 112
0
votes
1 answer

Ajax $.when returns different object when multiple parameters are used

I'm using jquery $.when to call a REST url which returns json. When I execute $.when with a single parameter I get different object in data1 result than when I execute multiple ones, even though return parameters should all be…
dendini
  • 3,842
  • 9
  • 37
  • 74
0
votes
2 answers

jQuery deferred - when multiple timeout tasks have completed

Having a few teething problems with $.deferred, $.when and $.done. I'm calling a method which has a couple of tasks inside on a timer. I'm looking at getting a callback when everything inside this method has completed, including the stuff in timers,…
TheCarver
  • 19,391
  • 25
  • 99
  • 149
0
votes
1 answer

$.when with arrays of functions is not working properly

Problem that I'm trying to solve: I want to have two arrays of ajax functions. One with topPriority that should run first, and another one with low priority that will start as soon as ALL of the topPriority calls are done. However, this functions…
Cacho Santa
  • 6,846
  • 6
  • 41
  • 73
0
votes
1 answer

jQuery do something WHEN an event happens

I'm trying to add 2 classes to a div, the first needs adding at the point WHEN scrolltop equals a certain amount, the second is added IF scrolltop is greater than a certain amount. Here is my jQuery code: var Scroll = $(window).scrollTop(); var…
Sam Skirrow
  • 3,647
  • 15
  • 54
  • 101
0
votes
0 answers

Correct use of $.when - done

I have a search function in a gallery that works by checking the search term against certain fields in a nested JSON. So far, it finds the terms I enter and returns an alert if it is not found. So the search works correctly in that sense, like…
Asinus Rex
  • 535
  • 9
  • 29
0
votes
3 answers

Making conditional Async calls using Jquery $when

I need to make two async (Second call needs to be made only when some condition is true) calls and when both the calls returns data, I need to make another call. For this I decided to use jquery $when. Before I make second Ajax call, I need to…
SharpCoder
  • 18,279
  • 43
  • 153
  • 249
0
votes
1 answer

SAPUI5 Wait for an Deferred-Object // wait for .done() function

I know there are several threads on this, but I think in SAPUI5 context no thread answers this general topic on deferred/sync calls in SAPUI5. In My Controller I got : test : function() { var dfd = $.Deferred(); var sServiceUrl =…
dotchuZ
  • 2,621
  • 11
  • 39
  • 65
0
votes
1 answer

Using $.when with JSONP with defined callback function

I'm building a dashboard where the user adds in a contributors details and then enters data for one or more blogs for that contributor. Each blog is added to the database through an api call using JSONP. (The JSONP callback function name is required…
0
votes
1 answer

Javascript/jQuery: control execution order (no ajax/php yet)

I spent hours reading posts all over the web about controlling execution order in Javascript/jQuery, but I still don't understand. I'm trying to write code that shows the execution progress of behind-the-scenes javascript on a webpage. I have a…
landau
  • 5,636
  • 1
  • 22
  • 50
0
votes
1 answer

jquery "$.when" function not working as expected

I am attempting to use the jquery $.when() function to prevent certain functions from being fired until the ajax completes. I have the below function but the deferred functions are still firing at the same time as the ajax call. code: …
arrowill12
  • 1,784
  • 4
  • 29
  • 54
0
votes
2 answers

JSONP ajax request and jQuery.when()

I have to make a bunch of JSONP calls, and execute some code after they all finish (or fail). i.e.: function finished() { alert('done!'); } function method1() { return $.ajax('http://example.org/endpoint', { data: { foo:…
user37315
  • 13
  • 3
0
votes
0 answers

Display text or preloader before sending multiple ajax calls in a jQuery when, then function?

I have an array of multiple ajax calls inside a when then function and would like to display a preloder or a text before every call. Let's say before every call I want to show: "processing task id 1..." and when finished then "processing task id…
Uuid
  • 2,506
  • 5
  • 28
  • 37
0
votes
3 answers

Tried $.when and $.then no lucky

I am trying to display some words and then when it is complete display the full sentence. the problem is doesn't matter which I try, it plays all together. Not one after the other. Can one of you explain to me what I am doing wrong? function…
user3750757
  • 37
  • 1
  • 6
0
votes
1 answer

.when Ajax success is done run another function with some jquery, almost working?

After a submit event runs with prevent default (to avoid the submit page refresh) along with some algorithms, the oneStory(id) function is called on success for sending the updated .put data to the node.js API. At this moment, the fields that were…
StackThis
  • 883
  • 3
  • 15
  • 45