views:

73

answers:

1
$.post("", {message: msg}, function() {
+3  A: 

That's the jQuery post method making a POST request to the current page (I'm guessing here, I'm assuming it just posts to the current page if that parameter is an empty string) with the contents of variable msg being passed as a parameter named message

John Sheehan
Just wondering... What if I need to pass more than one parameter?
Delirium tremens
The second parameter is a JSON object, so you could pass any valid JSON object: {message: msg, id: 1, active: true}
John Sheehan
you would need to know the parameter names and pass it... example {message: msg, secondParam: parm2, thirdParam: param3}
Roy Rico
@John: it's not JSON, it's a JS object, which is encoded into the request content using either urlencode, or mime-multipart. no JSON involved.
Javier
You are correct, I misspoke in my haste. Thanks for pointing that out.
John Sheehan