I have a jQuery plugin that calls a callback.
I’m passing in an object into the callback but there’s one thing I don’t know what to do about.
When the callback is called in one instance, it’s returning from an ajax call and is passing the response into the object.
In another case, it is passing a jQuery wrapped set of objects that are already loaded from ajax previously.
Should I call them both the same name, as they both represent the same content? Should they have different names as one is a string and the other is a jQuery?
What’s the convention for passing a jQuery object in a parameter object? Do I call it object.$response? Or should I forget that idea and just leave both object.response?
Suggest, in order of preference :
objorjObjdata. Be sure to include explanatory comment(s) in the code.In the second method you can branch inside the callback function as follows :