All Questions

3618
votes
25answers
941895 views

How do I return the response from an asynchronous call?

I have a function foo that makes an Ajax request. How can I return the response from foo? I tried to return the value from the success callback as well as assigning the response to a local variable i...
464
votes
6answers
117144 views

Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference

Given the following examples, why is outerScopeVar undefined in all cases? var outerScopeVar; var img = document.createElement('img'); img.onload = function() { outerScopeVar = this.width; }; im...
2447
votes
25answers
1134143 views

How can I upload files asynchronously?

I would like to upload a file asynchronously with jQuery. This is my HTML: <span>File</span> <input type="file" id="file" name="file" size="10"/> <input id="uploadbutton" type="b...
310
votes
3answers
208520 views

How to return value from an asynchronous callback function?

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...
21
votes
4answers
4969 views

How do I return the response from an Observable/http/async call in angular2?

I have service which returns an observable which does an http request to my server and gets the data. I want to use this data but I always end up getting undefined. What's the problem? Service: @Inj...
29
votes
2answers
11762 views

console.log() async or sync?

I am currently reading Async Javascript by Trevor Burnham. This has been a great book so far. He talks about this snippet and console.log being 'async' in the Safari and Chrome console. Unfortunatel...
521
votes
45answers
382978 views

How to check internet access on Android? InetAddress never times out

I got a AsyncTask that is supposed to check the network access to a host name. But the doInBackground() is never timed out. Anyone have a clue? public class HostAvailabilityTask extends AsyncTask<...
962
votes
12answers
577057 views

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created. I've added an Ajax call i...
23
votes
5answers
22382 views

NetworkOnMainThreadException

I just found out about NetworkOnMainThreadException at official docs and was wondering if the emulator is throwing this. I have been testing my app quite a bit and as far as I know all networking is ...
741
votes
16answers
551486 views

Asynchronous vs synchronous execution, what does it really mean?

What is the difference between asynchronous and synchronous execution?

Previous Next