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

Execute an Ajax request when another one is finished

I'm looping through a marker layer in a Leaflet map to catch the latitude and longitude of each marker and sending this coordinates in my database with Ajax. Then, when I've sent the latitude and longitude of each marker in my database, I want to…
Hippipers
  • 113
  • 2
  • 10
2
votes
1 answer

$.when promise object not working

I'm making concurrent AJAX requests but having an issue while trying to wait till all the calls have returned, console.log inside done() is showing result as an empty array. $.when isn't waiting for the requests to finish. var result = [] var…
Pratyay
  • 2,176
  • 1
  • 15
  • 14
2
votes
0 answers

When .. elsewhen equations seems to be reversed in Wolfram Systemmodeler

When I try this simple modelica code in Wolfram Systemmodeler: model bug Integer y(start = 1); equation when time > 0.2 then y = 5 "y = 2"; elsewhen time > 0.4 then y = 4 "y = 3"; elsewhen time > 0.6 then y = 3 "y = 4"; …
2
votes
1 answer

Execute function after multiple ajax calls

I wanted to fire a function when multiple ajax calls are completed. After some research I found the jquery $.when function. I tested this function but it doesn't work. Does anybody know how to solve this? var root =…
Y. Jacobs
  • 61
  • 6
2
votes
4 answers

jquery wait for ajax load to complete after click event

I'm working on a magento site which uses ajax layered navigation. When the user clicks on a color link in the layered nav it loads a list of the relevent products. I want to fire a click event after the ajax has completed. I thought I could use…
Holly
  • 7,462
  • 23
  • 86
  • 140
2
votes
1 answer

$.when.apply.done not executing asynchronous functions

I have to execute a callback function after all the asynchronous functions finishes execution. For that I have created an array, containing asynchronous functions: var funcs = []; var requests = []; In which I have pushed some ajax functions. This…
Rohini Choudhary
  • 2,423
  • 2
  • 21
  • 31
2
votes
1 answer

When and Deferred

I'm looping through an array, when all fileRead deferred are resolved, 'done' is logged. $.when.apply(null, $.each(files, function(index, file){ return self.fileRead.read(file).done(function(fileB64){ self.fileShow(file,…
user3729576
  • 237
  • 5
  • 10
2
votes
2 answers

Better way to handle a variable number of deferred requests in a JQuery $.when call?

I'm writing an app that at one point needs to get the result some number of requests before proceeding. This seems like a likely candidate for using JQuery's when. eg: // requests is an array of Deferreds $.when.apply(null,…
nedned
  • 3,552
  • 8
  • 38
  • 41
2
votes
2 answers

Why does fail() fired when there's no error in $.when()?

I"m using JQuery v2.0.0 I'm trying to understand the deferred objects and I got an unexpected result. The fail() was fired even though there's no visible or known error here. function foo1() { alert('testing'); } $.when(foo1()) …
fletchsod
  • 3,560
  • 7
  • 39
  • 65
2
votes
2 answers

Getting multiple ajax with jQuery.each, when (jQuery.when) all done do something

I wish to have a function which accepts an array of urls as argument, then downloads the json for each of those urls asynchronously, and when all are completed do some function. First I have a function that returns the ajax to get one url…
153957
  • 404
  • 6
  • 18
2
votes
2 answers

jquery.when done doesn't work: it's executed immediately

I've coded this in jQuery 1.7: $.when($.ajax({ type: "GET", url: internalOrderServiceURL, contentType: "application/json; charset=utf-8", dataType: "json", success: $.proxy(this.retrieveInternalOrderSuccess, this), error:…
marco_sap
  • 1,739
  • 2
  • 12
  • 12
1
vote
1 answer

Selecting Specific Data in an Data Frame to replace using the Row and Column names

I am attempting to replace specific NA values with 0 in my data table. I do not want all NAs replaces, only those under certain conditions. For example, "replace NA with Zeros when the row is Cole_1 and the Column includes the designation 'Fall1'".…
Rach B.
  • 13
  • 3
1
vote
0 answers

How can I write ansible condition when not changed?

I'm trying to write a when condition when registered value changed, failed, skipped and ok (desired state) cases but I can write for all 3 scenario other than ok tasks - name: task 1 module: register: result - name: task 2 module …
user3880406
1
vote
0 answers

Jquery: Call then function when all nested ajax calls are also complete

I am trying to write some nested ajax calls with the help of function and when. But currently, my then function is not working as expected. I want to call then function when all Ajax calls are done including the nested ones. I want to call then…
1
vote
1 answer

When condition in Pyspark dataframe

I have the below dataframe Column_1 Column_2 Column_3 A 1 A 2 A 3 A 4 A 5 B 1 B 4 B 5 C 1 C 2 I have to populate Column_3 based…
Padfoot123
  • 1,057
  • 3
  • 24
  • 43
1
2
3
11 12