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
    – lante
    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

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.