All Questions
Tagged with synchronous callback
47
questions
0
votes
1
answer
17
views
Node.js Callbacks in Synchronous Functions: Passing Functions as Arguments in Sequence (Nested One Inside The Other)... And Avoid Callback Hells
I didn't find many references to this specific question, so that's why I'm posting it even when it is pretty basic.
When we have to handle packages that require us to use callbacks in synchronous ...
-4
votes
4
answers
722
views
how can we combine synchronous function, callback function and promise all together
If I have three types of functions, which return, respectively,
A synchronous value:
function a(){
return 'a';
}
A callback:
function b(callback){
setTimeout(() => {
callback('b');
}, ...
0
votes
2
answers
112
views
Getting undefined for a variable even after defining it in a callback
I am using the following code for distance matric API for Google Maps, by using the google-distance-matrix API. The code is as follows:
app.get("/users", (req, res) => {
// console.log(req....
0
votes
0
answers
76
views
How to organize synchronous and asynchronous similar code
I wrote two functions doing the exact same thing, except the first take a synchronous callback, the second an asynchronous one:
const mySyncFn = function(callback) {
// A: prepare context
...
0
votes
0
answers
433
views
Javascript - how to synchronously preload images and then callback once they are all loaded
I'm trying to preload images from an array synchronously with a callback when all are done. I can find lots of solutions on here which get me near to where I want to be but none of them work ...
0
votes
1
answer
115
views
How to run the Callback function inside of the prototype in JavaScript?
According to this question and mdn.doc articles, I'm giving a Callback function inside of aprototype for managing the next code line after it's done.
But even if I create the Callback, the browser ...
2
votes
1
answer
921
views
synchronous while loop javascript
i want this output 1,1,1,....
instead of 2,1
i want to run synchronously
//just wait 2 seconds
function s(callback){
setTimeout(() => {
callback()
}, 2000);
}
a=[2]
...
-2
votes
1
answer
30
views
AJAX executes after calling function completes
Need JS to wait until the ajax completes(i.e. ajax success function executes), but Ajax is executing after the calling function completes. Added a callback but did not help. Log statements are ...
0
votes
0
answers
20
views
How to get Jquery synchronous or calback function before next function or code
I need help with this please.
I need one JQuery function to finish before the next one executes.
It is only client side so no requirement to contact the server, i.e. no POST or PUT or GET required.
It ...
2
votes
2
answers
878
views
What's the use of a callback function in PHP?
I'm in the process of learning PHP, and the concept of callback functions have me slightly confused. I understand that there are synchronous and asynchronous callbacks and that the common callback in ...
0
votes
2
answers
1k
views
How do i handle callback function response?
I understand the behavior of asynchronous nature however my other synchronous code depend on return value from the callback. How can i reformat the code to achieve that.
Module A
export function ...
0
votes
1
answer
269
views
Node.js add callback function to sqlite transaction
I am trying to find if a user exists in a table given an email and password but I can't get the function to return the right value (currently returns "false"), while the alert inside the function does ...
0
votes
2
answers
2k
views
Synchronous and Asynchronous callback functions in ES6 and Node [duplicate]
I'm new to ES6 and Node.js
I would like to understand how callback functions work in a synchronous environment and asynchronous environment.
I tried to run the following in Node:
function func1() ...
0
votes
1
answer
320
views
Handle events. One by one. Node.js
I have got this event listener:
manager.on('newOffer', (offer) => {
console.log(`We have a new offer :#${offer.id}`.bgGreen);
getInventory( function(){
processTradeOffer(offer);});});
My problem ...
0
votes
1
answer
935
views
nodejs call two class functions synchronous
I have two class functions in nodejs and I want to call both synchronously both one after another.
var questionData = questionModelObj.getQuestionbyId(req.params.id);
var answerData = answerModelObj....