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) { var json = transport.responseText.evalJSON(true); var errors = $H(json.errors); if (errors.size() > 0) { this.form.down('.error').show(); errors.each(function(pair) { this.showError(pair.key, pair.value); }.bind(this)); } else { this.form.submit(); } } When the JSON received looks like {"errors":[{"anError": "aMessage"}]}, errors.size() works which means the errors are displayed as they are supposed to, but when the json received looks like {"errors":[]}, then errors.size() falls over as errors is an undefined object. Basically, what is the correct way to get the size of the returned JSON data reliably with Prototype 1.6? $H() does not work when errors is empty. I know the hash was one of the biggest changes moving to 1.6.. I'd appreciate any light someone can shed on this. I have tried checking if its null, or its length with no success. Regards, laf. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---