Is there a reason why I should use
syntax 1
$.ajax({
url: url,
data: {foo: "foo", bar: 1}, // everything is declared
success: success,
dataType: dataType
});
And not syntax 2
$.ajax({
url: url,
data: {foo: valueOfFoo(), bar: calculateBar(100)}, // reference to functions
success: success,
dataType: dataType
});
When sending objects to a controller?
The jQuery API definition says that the type of data can be an object or a string that is sent to the server with the request.
Somehow I think that syntax 1 is "safer", but this might be superstition (paired with my experience from countless hours of bugfixing) and I can not be sure about it.