Linked Questions
11,139 questions linked to/from How do I return the response from an asynchronous call?
544
votes
5
answers
1.3m
views
jQuery: Return data after ajax call success [duplicate]
I have something like this, where it is a simple call to a script that gives me back a value, a string..
function testAjax() {
$.ajax({
url: "getvalue.php",
success: function(data) {...
579
votes
3
answers
506k
views
How to return value from an asynchronous callback function? [duplicate]
This question is asked many times in SO. But still I can't get stuff.
I want to get some value from callback. Look at the script below for clarification.
function foo(address){
// google map ...
137
votes
11
answers
471k
views
Returning data from Axios API [duplicate]
I am trying to use a Node.JS application to make and receive API requests. It does a get request to another server using Axios with data it receives from an API call it receives. The second snippet is ...
188
votes
4
answers
344k
views
How to return values from async functions using async-await from function? [duplicate]
How can I return the value from an async function?
I tried to like this
const axios = require('axios');
async function getData() {
const data = await axios.get('https://jsonplaceholder.typicode....
134
votes
5
answers
190k
views
Get return value from setTimeout [duplicate]
I just want to get the return value from setTimeout but what I get is a whole text format of the function?
function x () {
setTimeout(y = function () {
return 'done';
}, 1000);
...
104
votes
4
answers
256k
views
Returning a value from callback function in Node.js [duplicate]
I am facing small trouble in returning a value from callback function in Node.js, I will try to explain my situation as easy as possible. Consider I have a snippet, which takes URL and hits that url ...
106
votes
3
answers
311k
views
How to return data from promise [duplicate]
I need to get the response.data out of the promise so it can be returned by the enclosing function. I know, I probably can't do it the way I've coded it because of normal JavaScript scope. Is there ...
112
votes
4
answers
260k
views
How to make code wait while calling asynchronous calls like Ajax [duplicate]
I am looking for something like this
function someFunc() {
callAjaxfunc(); //may have multiple ajax calls in this function
someWait(); // some code which waits until async calls complete
console.log(...
65
votes
4
answers
118k
views
JavaScript: Global variables after Ajax requests [duplicate]
the question is fairly simple and technical:
var it_works = false;
$.post("some_file.php", '', function(data) {
it_works = true;
});
alert(it_works); # false (yes, that 'alert' has to be ...
88
votes
2
answers
161k
views
jQuery getJSON save result into variable [duplicate]
I use getJSON to request a JSON from my website. It works great, but I need to save the output into another variable, like this:
var myjson= $.getJSON("http://127.0.0.1:8080/horizon-update", function(...
61
votes
2
answers
126k
views
JavaScript wait for asynchronous function in if statement [duplicate]
I have a function inside an if statement
isLoggedin() has an async call.
router.get('/', function(req, res, next) {
if(req.isLoggedin()){ <- never returns true
console.log('...
46
votes
7
answers
45k
views
jQuery Ajax call - Set variable value on success [duplicate]
I have an application that I am writing that modifies data on a cached object in the server. The modifications are performed through an ajax call that basically updates properties of that object. ...
28
votes
6
answers
108k
views
JavaScript function that returns AJAX call data [duplicate]
I would like to create a JavaScript function which returns the value of a jQuery AJAX call. I would like something like this.
function checkUserIdExists(userid){
return $.ajax({
url: '...
56
votes
2
answers
75k
views
How to block for a javascript promise and return the resolved result? [duplicate]
I am obviously misunderstanding something about either the way js promises are resolved or about the semantics of "return."
I am being called by a function that expects me to be synchronous - to ...
28
votes
2
answers
31k
views
JavaScript asynchronous return value / assignment with jQuery [duplicate]
I have the following jQuery Function. I'm trying to return the GUID value shown here in the alert(); The alert works fine and the value is populated, however I can't seem to assign it to a variable ...