Don't let spaces between the object and its key, nor inside the arrays.

Dormilich

07-26-2010, 12:21 PM

to elaborate on that, if data were an array data = []; its length after you defined the properties (login, settings) would still be zero. JavaScript Arrays are always numerically indexed, if you assign additional properties, you assign them to the Object part, not the Array part.

Kor

07-26-2010, 01:13 PM

to elaborate on that, if data were an array data = []; its length after you defined the properties (login, settings) would still be zero. JavaScript Arrays are always numerically indexed, if you assign additional properties, you assign them to the Object part, not the Array part.
Yes, except that, the way the it is is, OP does not use the length of data, it uses the length of one of data's elements (data['login'] or data['settings']). Now those elements are arrays, thus they have a length. :)

martynball

07-26-2010, 01:39 PM

Thanks, figured out why it wasn't working. The ID was actually a element, not an ID.

IE: function(this).

Fixed it now thanks :)

Dormilich

07-26-2010, 02:05 PM

Yes, except that, the way the it is is, OP does not use the length of data, it uses the length of one of data's elements (data['login'] or data['settings']). Now those elements are arrays, thus they have a length. :)

I was fully aware of that and I didnít doubt it either, I was just explaining why you proposed data = {}; over data = [];