On Jun 21, 4:26 am, Sidney San Martín <[email protected]> wrote:
> To an extent, I agree… but how would you write a function like jQuery.ajax,
> which takes upwards of 30 optional parameters, in a more JavaScripty way?
Provide your own constructor:
function Ajax(...) {
...
}
var req = new Ajax(...);
req.accepts = ...;
req.cache = ...;
...
or, if you have an "extend" function to copy properties:
var req = new Ajax(...);
extend(req, {
accepts: ...,
cache: ...,
...
};
but supplying an object up front is more straight forward.
The reason jQuery has to deal with 30+ parameters is that it tries to
be all things to all developers. If you are writing a function for a
specific purpose (as most script is), then you can roll your own AJAX
request with only the formal parameters you require.
--
Rob
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]