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

Can you have embedded when.applys() in jQuery?

I'm trying to use 2 $.when.apply()'s with $.ajax and $.getJSON. I'm trying to embed one inside the other, but it doesn't seem to be working. Here's the outline: var jxhr = []; var kxhr = []; $.when($.getJSON('stuff.js', function(cart){ //Grab…
ballofpopculture
  • 741
  • 1
  • 9
  • 18
1
vote
1 answer

How to *when* an array of deferreds

I am trying to make an ajax call for each item in an array. Right now i throw all the promises into an array and then do $.when.apply... // throw all the promises into an array _.each(birds,function(bird,i){ birds[i] = getBird(bird) // getBbird…
Shanimal
  • 11,517
  • 7
  • 63
  • 76
1
vote
2 answers

$.when.done callback isn't working

The following code has a bad syntax error. Probably because I'm using 'for' or something. $.when( for (var i=0; i < 5; i++) { $.getScript( "'" + someArr[i].fileName + ".js'"); } $.Deferred(function( deferred ) { $(…
Ori Refael
  • 2,888
  • 3
  • 37
  • 68
1
vote
2 answers

Backbone.js render a view after a getting return value

In the code below I need to render the view only after I have got valuea from a call on the Gmaps navigator. Until I have Latitude amd Longitude I can't render the view. Followinag some answers here I'm stuck with the error Object [object global]…
Arcanis
  • 33
  • 4
1
vote
3 answers

How to return the contents of the page loaded by .post, when encased in .when?

This is the basic framework of my page: $.when(postrequest1, postrequest2).then(function () { // how do I access the results of postrequest1 and postrequest 2 here? });
Lucas
  • 16,930
  • 31
  • 110
  • 182
1
vote
1 answer

Using an array of deffered with jQuery.when()

I'm using $.when to run 2 functions prior to some other logic. Now, in several cases I need to run a different set of functions prior to doing that same logic, so I wanted to pass an array of the functions to $.when, but couldn't make it…
Haji
  • 1,715
  • 7
  • 25
  • 41
0
votes
1 answer

When should I use SELECT CAST or SELECT SAFE_CAST instead of just CAST in SQL?

Would there be much difference if I used CAST instead of SELECT CAST or SELECT SAFE_CAST? Thank you in advance. I'm having trouble understanding when to use these. I understood CAST but then I learned SELECT CAST and SELECT SAFE_CAST wondering if…
0
votes
1 answer

Convert column to list by using when with 2 dataframe

I have two Dataframe and I want when the column CONCERN of Dataframe2 contains 'all' the anwser in the new column "EFFECTIFITY" (in the same dataframe) is a list off all the serial number "SN" of the column "SN" in the Dataframe1 df1 =…
SISI
  • 1
  • 1
0
votes
0 answers

jQuery $.when - What are the difference between these two elements? One executes instantly, the other works

So imagine we have a product page that initially loads an empty price div, and that div is later populated async after page load. Using this code we wait until the price appears to have populated, and then execute a function to copy this price…
5rowaway
  • 1
  • 1
0
votes
1 answer

purrr::when() doesn't evaluate first condition

Apart from the more common purrr::case_when that elegantly performs a vectorised if-else statement, there is less known variant purrr::when which is non-vectorised yet still useful in many scenarios. Like purrr::case_when, the purrr::when syntax…
Agile Bean
  • 6,437
  • 1
  • 45
  • 53
0
votes
1 answer

Unable to set multiple conditions in when clause for ansible roles

My ENV is DEV while the instance_name is myapp44 Thus, i want the role for myapp7 to skip as the when condition fails. Below is my role that works fine and skips as the when clause fails. - { role: myapp7, ENV: "{{ENV}}", ACTION: "{{ACTION}}", when:…
Ashar
  • 2,942
  • 10
  • 58
  • 122
0
votes
0 answers

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.val() === `` || e.type === `dragover`) { …
Chris
  • 650
  • 7
  • 20
0
votes
0 answers

jquery .when function not trigger

In the following function, the $.when() never triggers. It goes right to the .then(). None of the console.log statements within that function fire, nor does the ajax query when it meets the criteria that would trigger the…
Chris
  • 650
  • 7
  • 20
0
votes
2 answers

I am looking for the command in a program that filters only when 3 letters are entered

I am looking for the command in a program that filters only when 3 letters are entered. Does anyone know what command or code I need to look for to find this? Maybe it's also a Vue-Command, because my program is written in Vue.js. Thank you
0
votes
1 answer

Dynamically call getJSON inside $.when block

Is there some way to rewrite this in less lines of code, by making it dynamic instead of doing multiple similar calls with different indexes? var input = getInput(); var URL = getEndpointURL(); var results = []; $.when( …
Lucas Mendonca
  • 387
  • 3
  • 13