jQuery: The Write Less, Do More JavaScript Library

ajax options parameter

View: New views
3 Messages — Rating Filter:   Alert me  

ajax options parameter

by Markw65 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The ajax options parameter, unlike every other(?) options parameter,
is used "in place".

        ajax: function( s ) {
                // Extend the settings, but re-extend 's' so that it can be
                // checked again later (in the test suite, specifically)
                s = jQuery.extend(true, s, jQuery.extend(true, {},
jQuery.ajaxSettings, s));

This means you cant use the same options object (with modifications)
to successive calls to $.ajax. ie, I'd like to do:

var ajOpts = {...};
$.each(foo, function() { ajOpts.data.id = this.id; $.ajax(ajOpts) });

This would have worked if ajax were defined as:
        ajax: function( s ) {
                s = jQuery.extend(true, {}, jQuery.ajaxSettings, s);

which seems to be the "standard" way of doing things.

The comments say its done this way for the test suite - but surely the
test suite could just use a callback (eg beforeSend) to get the
modified object back?

Or am I just wrong to think that this should work?

Mark

--

You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@....
To unsubscribe from this group, send email to jquery-dev+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.



Re: ajax options parameter

by dave.methvin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> The ajax options parameter, unlike every other(?) options
> parameter, is used "in place".

That does seem kind of fishy. I don't recall seeing a ticket for this,
it's at least worth considering. Do you want to create one at
dev.jquery.com?

--

You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@....
To unsubscribe from this group, send email to jquery-dev+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.



Re: ajax options parameter

by Markw65 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket # 5439 created.

Mark

On Oct 30, 8:12 pm, Dave Methvin <dave.meth...@...> wrote:
> > The ajax options parameter, unlike every other(?) options
> > parameter, is used "in place".
>
> That does seem kind of fishy. I don't recall seeing a ticket for this,
> it's at least worth considering. Do you want to create one at
> dev.jquery.com?

--

You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@....
To unsubscribe from this group, send email to jquery-dev+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.