0
function images(url, somextra, callback)
{
    var img = new Image();
    img.onload = function() {
        callback(url , somextra);   
    };
}

function call(url, extra)
{
}

images(someurl, stuffs, call);

When I am passing 2 arguments my programs just hangs. How can I pass two arguments and a callback function in my images function?

2
  • 3
    It's not the "two arguments", this would act just the same with one argument. You're not loading the image at all... try adding img.src = url or something. Commented Jul 25, 2014 at 18:56
  • your code just seems to pass arguments with a callback function Commented Jul 25, 2014 at 18:59

2 Answers 2

1

You should clear you concept !!!! it does not matters if one or more than one argument.

img.src = url

try to add image url after imag.onload

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

Comments

1

You are setting a the callback up on the onload event, but you are not loading the image.

Try setting up the source for the image like this.

function images(url ,somextra , callback)
{
    var img = new Image();
    img.onload = function(){
         callback(url , somextra);   
    };
    // set the source url here
    img.src = "example/url/image.png"
 }

 function call(url , extra){

 }
 images( someurl , stuffs , call);

Otherwise your onload event never fires and therefore the callback is not called.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.