A perfectly reasonable question. :-) In JavaScript, you do not have to call a function with as many arguments as it defines, and you do not need to define as many arguments as you can call. This can be confusing if you are used to more limited environments. :-)
Response Features:
1) What does the function (msg) {ServiceSucceeded (msg)} mean?
Defines a function (anonymous) that takes one named argument ( msg ) and calls ServiceSucceded , passing in that argument. jQuery will call a function with three arguments defined in the jQuery documentation for the success function, but in this particular success function, only the first one ( data ) is used. Read more about the named functions and anonymous functions here .
2) What is "msg" in this context?
The first argument to the function. jQuery docs call this first data argument, but you can call it whatever you want.
3) How, in fact, I wanted to know how to structure the sugnature method for success?
You did the right thing, this is in the jQuery documentation.
This thing about function arguments can be confusing, so let's do some examples:
function foo(arg) { alert(arg); }
It is very clear that I am defining a function called foo that takes one named argument, arg . And thus:
foo("Hi there"); // alerts "Hi there"
But I can also do this:
foo(); // alerts "undefined"
There I did not give any arguments for foo , so inside foo , arg is undefined.
I can also do this:
foo("Hi there", "again"); // alerts "Hi there"
I call foo with two arguments, but foo uses only one of them.
I could define foo to use as many arguments as you go:
function foo() { var index; for (index = 0; index < arguments.length; ++index) { alert(arguments[index]); } }
arguments is an automatic thing that all functions have, which is a pseudo-array (this is not really an Array ) of the actual arguments with which the function was called. So:
foo("Hi there", "again"); // alerts "Hi there", and then alerts "again"
You can even mix named and unnamed arguments:
function foo(arg) { var index; alert(arg); for (index = 1; index < arguments.length; ++index) { alert("[" + arguments[index] + "]"); } }
So now
foo("Hi there", "again"); // alerts "Hi there" and then alerts "[again]"
Pay attention to the [] around the second warning, because I started the loop with index 1 , not zero.
arguments and named args are related:
function foo(arg) { alert("arg = " + arg); alert("arguments[0] = " + arguments[0]); arg = "Updated"; alert("arg = " + arg); alert("arguments[0] = " + arguments[0]); }
If I do foo("Hi"); This shows the following warnings:
arg = Hi
arguments [0] = Hi
arg = Updated
arguments [0] = Updated
(There is a different way if you update arguments[0] .)