Nature of Javascript

satya - Sat Apr 28 2012 07:12:55 GMT-0400 (Eastern Daylight Time)

See this code


$.ajax({
  url: "test.html",
  cache: false
}).done(function( html ) {
  $("#results").append(html);
});

satya - Sat Apr 28 2012 07:14:05 GMT-0400 (Eastern Daylight Time)

$ is a function


var x = $("hello there");
var x = function1("argument");

satya - Sat Apr 28 2012 07:14:58 GMT-0400 (Eastern Daylight Time)

$ is also an object


var y = some-js-object;
var x = $.ajax(y);

satya - Sat Apr 28 2012 07:17:47 GMT-0400 (Eastern Daylight Time)

An argument can be a json object


var y = {
  url: "test.html",
  cache: false
};

var x = $.ajax(y);

function myfunc(html)
{
   //do something
}

x.done(myfunc);

satya - Sat Apr 28 2012 07:18:29 GMT-0400 (Eastern Daylight Time)

How do I know what get passed to a jquery call back method?

How do I know what get passed to a jquery call back method?

Search for: How do I know what get passed to a jquery call back method?

satya - Sat Apr 28 2012 07:26:16 GMT-0400 (Eastern Daylight Time)

The writer has to document what the callback function expects: example


complete(jqXHR, textStatus)

This call back function expects two arguments. The documentation also has to indicate the nature of each argument. See an example here