[jQuery] Re: closure inside ajax method

2009-01-28 Thread bob
I think the following line is the problem files = files.concat($.map(src.match(scripts).pop().split(','), function(e,i){ count = files.length; // gives me 0 or undefined

[jQuery] Re: closure inside ajax method

2009-01-28 Thread bob
Thanks everybody, to Eric Garside : I have tried "jQuery Automatic Script Includer" and it does not download scripts for me. Are there any known issues that I should be aware of? I placed this code inside of jquery.js right at the end. (function($){ var scripts = /\?(.*)/, files = [],

[jQuery] Re: closure inside ajax method

2009-01-27 Thread Andrew Hedges
The order of elements in a simple array like this is guaranteed. Looping over an object with a for in loop, the order is not guaranteed, though by convention most browsers honor the order in which the elements were added. jQuery would have to go out of its way to return the elements from your arra

[jQuery] Re: closure inside ajax method

2009-01-27 Thread Mike Alsup
> Can't closure be achieved with for loop? > for(var i=0; i Does $.each process the "scripts" array items in the exact order they are in > the > array? Yes.

[jQuery] Re: closure inside ajax method

2009-01-27 Thread bob
Thanks, Can't closure be achieved with for loop? for(var i=0; i

[jQuery] Re: closure inside ajax method

2009-01-27 Thread Mike Alsup
> How can access index i inside of "complete" method? > The following gives me just the last value of i. > > var scripts = ['script1.js', 'script2.js']; > > for(var i=0; i >         jQuery.ajax({ > >                         dataType: 'script', >                         url: scripts[i], >          

[jQuery] Re: closure inside ajax method

2009-01-27 Thread Eric Garside
I've actually posted code before that does exactly what you're trying to do. Check out the function here: http://snipplr.com/view/10368/jquery-automatic-script-includer/ On Jan 27, 7:57 am, Beres Botond wrote: > That *should* get called twice. What does debug() do? > If you put alert() instead

[jQuery] Re: closure inside ajax method

2009-01-27 Thread Beres Botond
That *should* get called twice. What does debug() do? If you put alert() instead of it, it will still be just 1 alert? Also If you can test it in Firefox with Firebug addon (http:// getfirebug.com/), you should be able to see if there are actually 2 requests going out correctly (and the response t