Linked Questions

547 votes
5 answers
1.3m views

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.3k
581 votes
3 answers
510k views

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.9k
138 votes
11 answers
484k views

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,483
193 votes
4 answers
362k views

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,498
136 votes
5 answers
195k views

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,323
105 votes
4 answers
258k views

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
317k views

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
113 votes
4 answers
261k views

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.5k
66 votes
4 answers
119k views

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.7k
65 votes
2 answers
130k views

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
  • 839
88 votes
2 answers
161k views

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
46 votes
7 answers
45k views

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,445
28 votes
6 answers
108k views

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
78k views

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

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
742