In the first example, you call $.getand then pass its return value to setTimeout. In the second example, you do not call this function at all; you provide a setTimeoutfunction that will be called later, after which you will call $.getfor you.
This is easier to see in a simpler case:
function test() {
alert("Hi there!");
}
// WRONG, *calls* `test` immediately, passes its return value to `setTimeout`:
setTimeout(test(), 1000);
// Right, passes a reference to `test` to `setTimeout`
setTimeout(test, 1000);
, (()), - .
, , :
function test(msg) {
alert(msg);
}
setTimeout(test("Hi there!"), 1000);
setTimeout(function() { test("Hi there!"); }, 1000);