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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The viewer will learn how to dynamically set the form action using jQuery.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

688 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