-3

I am trying to figure out someone else's codes. It is written by Javascript. I am more familiar with Jquery.

I know it's a function but not sure that these parameters for (imaglist,sucess, hobject). Thanks for the help.

var mystuff = new Object();

var all_done = function (imagelist,success,hobject){
  //alert(success);


mystuff = imagelist.list;

}
FlyingCat
  • 14,036
  • 36
  • 119
  • 198
  • 4
    We don't know what the parameters are used for either, since we did not write the code. Have a look how the function is called and try to figure it out. – Felix Kling Aug 01 '12 at 17:38
  • This may be just a fraction of the whole code, so it's quite hard to figure out what the code should do. – Endre Simo Aug 01 '12 at 17:39
  • Since all we basically have to go on is the name of the variable (thanks to Javascript, we don't even know type), there's really nothing we can do to help. Name can be a rough guideline, but it's up to you to find where this function is called, and figure it out from there. – Dennis Meng Aug 01 '12 at 17:41
  • jQuery is JavaScript. I strongly suggest learning more plain JavaScript. It will greatly improve your understanding of jQuery as well. Objects and functions aren't really rare to use in combination with jQuery – René Aug 01 '12 at 17:41
  • "It is written by Javascript. I am more familiar with Jquery." You are aware that even jQuery is just a framework written in and utilizing JavaScript? – Torsten Walter Aug 01 '12 at 17:41

4 Answers4

2

Technically it's just a function, with imagelist, success, and hobject as parameters. So you'd call it like :

all_done(anImagelist, somethingRepresentingSuccess, myHobject)

But in this case, it looks like all_done is a callback function, which is called when something (not shown here) finishes. imagelist, success, and hobject are callback variables, which are results of whatever function the callback is assigned to.

Lets say we have an ajax call, like this:

$.ajax({
   type: "POST",
   data: something,
   success: all_done
});

now when the ajax call is completed, the results of it, assuming there are three, will be passed to all_done. Really I'm not even sure if this is possible with an ajax call, but the idea is what's important. So, when the ajax call is complete, mystuff will be set to imagelist.list;

Phillip Schmidt
  • 8,805
  • 3
  • 43
  • 67
  • @FelixKling just an assumption, given that it is called "all_done" and there is a commented out `alert("success")`, lol. I was assuming the OP wanted to know what it *does*, not what it *is*. I'll edit and clarify, though – Phillip Schmidt Aug 01 '12 at 17:46
  • yes this is a ajax callback function. – FlyingCat Aug 01 '12 at 17:48
  • @Flying: You should include relevant information in your question, from the beginning. – Felix Kling Aug 01 '12 at 17:51
1

It's a function accepting three parameters (imagelist, success, and hobject). You can call it with all_done(some_list, some_state, some_object);

It's basically the same as writing the function like this:

function all_done(imagelist, success, hobject) {
  // ...
}
knittl
  • 246,190
  • 53
  • 318
  • 364
1

You have your mystuff Object to which you can attach any properties you want. Then you have all_done which stores a function that receives imagelist,success,hobject and when that function it's triggered whatever you sent to it as imagelist wich is also an object that must contain the attribute list will be attached to the mystuff Object

Isaac Gonzalez
  • 1,734
  • 1
  • 16
  • 22
0

Not sure, but it stores a function into a variable named all_done. If the all_done function was called right after the code you posted, then mystuff becomes imagelist.list:

    var imagelist = {list:"myList"};
    var mystuff = new Object();
    var all_done = function (imagelist,success,hobject){
    //alert(success);
    mystuff = imagelist.list;
    }
    all_done(imagelist,true,null);
    alert(mystuff==imagelist.list);//should alert true
    alert(mystuff);//should alert myList
sorry
  • 11
  • 2