Linked Questions

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) {...
Francesco's user avatar
  • 25.2k
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 ...
Gowri's user avatar
  • 16.8k
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 ...
bunkerguy's user avatar
  • 1,473
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....
King Rayhan's user avatar
  • 2,452
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); ...
Vainglory07's user avatar
  • 5,253
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 ...
Pradeep Simha's user avatar
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 ...
Craig's user avatar
  • 1,794
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(...
thecodejack's user avatar
  • 13.3k
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 ...
Gal's user avatar
  • 23.6k
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(...
user1229351's user avatar
  • 2,035
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('...
pfMusk's user avatar
  • 799
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. ...
Nathan's user avatar
  • 1,435
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: '...
Timothy Ruhle's user avatar
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 ...
Chris Owens's user avatar
  • 1,137
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 ...
patrick's user avatar
  • 451

15 30 50 per page
1
2 3 4 5
743