All Questions

3436
votes
23answers
904828 views

How do I return the response from an asynchronous call?

I have a function foo which 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 ...
445
votes
6answers
110336 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...
2397
votes
25answers
1117208 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...
295
votes
3answers
197085 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...
27
votes
2answers
10769 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...
519
votes
45answers
376087 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<...
935
votes
12answers
562764 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...
14
votes
4answers
3011 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...
23
votes
5answers
22226 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 ...
723
votes
16answers
527489 views

Asynchronous vs synchronous execution, what does it really mean?

What is the difference between asynchronous and synchronous execution?

Previous Next