-1

This has been addressed, please see the answer located at -> Create a custom callback in JavaScript

5
  • without seeing what's returned in your "data"... hard to tell Commented Feb 16, 2014 at 15:58
  • The returned data could be anything. Let us assume it is the responseText of google which contains the google.com source. Commented Feb 16, 2014 at 15:58
  • 3
    I don't understand what eval() has to do with invoking a callback. If you pass a function as a callback, then the function can just be called. The question really isn't clear. Commented Feb 16, 2014 at 15:59
  • 2
    replace if (typeof (b) !== 'undefined') with if (typeof (b) === 'function ') ` and do b(); Commented Feb 16, 2014 at 16:00
  • @yivi - Why are you responding to a 7 year old question that I already edited 6 years ago to include the same link listed in your comment? Commented May 16, 2021 at 12:35

1 Answer 1

2

You can use b() to invoke the function "b" if it is a function. You can also use the apply method to invoke a function. On the subject of callbacks, you may be interested in this article about the Promise API, since it provides an example of "get" and "getJSON" method that are consistent with this API.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.