[Proto-Scripty] Re: JSON and $H() to get size of returned JSON data

2008-11-22 Thread Tobie Langel
I suggest you read my previous comments about $A, and reponseJSON. $H is not made to iterate over arrays. To iterate over arrays, just use each Like so: [1, 2, 3].each(function(e) { console.log(e) }); Best, Tobie On Nov 22, 3:14 am, laf <[EMAIL PROTECTED]> wrote: > Thanks All, > > I manage

[Proto-Scripty] Re: JSON and $H() to get size of returned JSON data

2008-11-22 Thread laf
Thanks All, I managed to get it work like so; onFormSuccess : function(transport) { var json = transport.responseText.evalJSON(true); if(json.errors.length == 0) { this.form.submit(); } else { var errorHash = $H(json.errors);

[Proto-Scripty] Re: JSON and $H() to get size of returned JSON data

2008-11-18 Thread Tobie Langel
if json.errors is an array, you don't need $A. $A is for iterables only (like dom node collections, for example). Best, Tobie On Nov 19, 5:01 am, "Jerod Venema" <[EMAIL PROTECTED]> wrote: > It looks like json.errors should be an array, right? > > var json = {"errors":[]} > > json.errors is an

[Proto-Scripty] Re: JSON and $H() to get size of returned JSON data

2008-11-18 Thread Jerod Venema
It looks like json.errors should be an array, right? var json = {"errors":[]} json.errors is an array...so $H(json.errors) is probably not what you want. Try $A(json.errors); You'll have to adjust your each as well... $A(json.errors).each(function(err){ console.log(err.anError); //outputs "a

[Proto-Scripty] Re: JSON and $H() to get size of returned JSON data

2008-11-18 Thread Tobie Langel
FWIW, you should be using response.responseJSON and setting the sanitizeJSON option of your ajax request to true. Would avoid evaluating the json object twice! Best, Tobie note: you'll need to set the mime-type of the response to 'application/ json' or the evalJSON option to 'force' On Nov 19

[Proto-Scripty] Re: JSON and $H() to get size of returned JSON data

2008-11-18 Thread kangax
On Nov 18, 6:48 pm, laf <[EMAIL PROTECTED]> wrote: > So I have this function. It toggles error messages after an AJAX call > for validation. It works fine in prototype 1.5, > but an upgrade to 1.6 has broken it and I have not been able to work > out why. > >     onFormSuccess : function(transport)