13

Today I marked https://stackoverflow.com/questions/30543171/a-callback-function-doesnt-work-in-an-asynchronous-call as a duplicate of How do I return the response from an asynchronous call? (Actually the OP asked the same question earlier, and I had closed it as duplicate).

As it is clear both the questions are regarding handling the value returned by an asynchronous method call in JavaScript. Now is that enough to mark it as duplicate? Was I right in doing so?

Also even after marking it as duplicate I had tried to offer some help to OP by suggesting some code snippets in JSFiddle.

Now the OP is again asking to reopen the question since their issue is not resolved. How should these sorts of cases be handled?

5
  • I linked the OP to your meta-question. Commented May 30, 2015 at 10:43
  • In my first post you answered that I need to implement callback and closed topic. And I implemented callback, but nothing changed. I was forced to create a new topic, because then no one comes to indoor.
    – Bob Napkin
    Commented May 30, 2015 at 12:55
  • 6
    There is a practical limit to what can be accomplished in Q+A. The OP needs a brain transplant to get ahead, we can't help him get one. This is a job for a teacher. Commented May 30, 2015 at 15:33
  • 6
    @bob why would there be any difference between returning in the first async call (under VK.Api.call) and returning in the anonymous function passed to getFriends? You essentially moved the return statement to another place; that won't fix the problem. If you read and took the time to fully understand the canonical your first post was marked as a duplicate of, you wouldn't've had to ask a second question—I assure it.
    – royhowie
    Commented May 31, 2015 at 21:33
  • Is it wrong to say that questions should describe symptoms. But duplicates are based on the cause ? Commented Jun 1, 2015 at 9:12

1 Answer 1

23

The issue in their question is directly related to them attempting to return a value from an asynchronous callback function in JavaScript. The duplicate rightly explains that it is impossible for the OP to do exactly what they want (i.e. running an asynchronous function as if it was synchronous).

If they are not able to solve their problem given the detailed and precise question they were linked to, that should not be our problem. We do not have an obligation to do their work for them, and any answer to the OP's question would just rehash what was stated in the canonical question.

4
  • meta.stackoverflow.com/questions/295617/…
    – Bob Napkin
    Commented May 30, 2015 at 12:55
  • If it's impossible why he told me 'you need to use a callback method'?
    – Bob Napkin
    Commented May 30, 2015 at 13:00
  • 9
    @bob: it is impossible to do exactly as you asked (i.e. friends === list immediately upon assignment). One common workaround is to structure your application to use callbacks so that this is not necessary, but this requires all of your asynchronous code to use callbacks. You might want to read the duplicate question linked more closely which explains this in more detail. Commented May 30, 2015 at 13:11
  • 2
    @bob, it is frequently good idea to type your question into search box of your favorite search engine first. I.e. bing.com/search?q=javascript+why+need+to+use+a+callback+method will give you link to stackoverflow.com/questions/7070495/…. At that point you should have enough information to either get answer to your question OR prepared to ask much better question than you'd do otherwise. Commented May 31, 2015 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .