Skip to content

modifying the *"RIGHT"* example adding a return #481

Closed
@jgomo3

Description

@jgomo3

Reading this section of how Jquery Works i think the example could be enhanced.

Programmer should not now how will the get function use the callback function, so it is possible that get will use its return value. In that hypothetical case, this example will fail.

Always use return when wrapping a callback function like that because it will satisfy both cases:

  • Returning values functions
  • Non returning values functions.

So i suggest modifying the "Right" example with the following:

$.get( "myhtmlpage.html", function() {

    return myCallBack( param1, param2 );

});

(It just add a return before the callback call).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions