Javascript with callback

Posted on 2011-03-01
Last Modified: 2012-05-11


I have a simple piece of example code, in which I am passing a function (for call back) into a class.
When this function is called back, I wish to have a parameter passed back but this is not working.

Thanks for you help

<!DOCTYPE html>

<script language='javascript' type='text/javascript'>

function init() {
    var y;
    var myClassObj = new MyClass(5, calledBack); 

function calledBack(x) {
    alert("Got called back with "+x);

function MyClass(val, f)
    var data = val;
    function someFunc(x) 
       alert("someFunc "+x);;


<div style="" >



Open in new window

Question by:BeerFizz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Accepted Solution

jasonduan earned 500 total points
ID: 35012289
change your code line #28 from;

Author Closing Comment

ID: 35012321
Perfect!  Thank you.

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL to JSON 14 39
Cannot exit IF statement in PowerShell 4 24
HTML CSS and  Table design 4 11
isNaN issue on the Table input text 2 4
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question