[jQuery] Reading json strings

[jQuery] Reading json strings

<html>
<body>
Hi folks,
I don't understand what I'm doing wrong in the following code
(<a href="http://temporarius.massey.ac.nz/json_test.htm" eudora="autourl">
http://temporarius.massey.ac.nz/json_test.htm</a>) where I cannot seem to
"harvest" the returned json string.
The test json string being returned after the form is submitted
is:
<pre>{"fields": [{"id": "name",
"isValid": false, "message": "Username must be
at least 3 characters long"}]}
</pre>(there is absolutely no connection to the contents of the form
being passed to the server and the json string returned - I'm just trying
to understand the system)
My jq code is<font face="Courier New, Courier">:
$(document).ready(function() {  
        var AFoptions = {
           
before:   fnAF_Before('7'),
           
dataType: 'json',
           
after:    function(json) {
               
if (json.fields) {
                       
alert(json.fields.length);
                   
for (var i = 0; i < json.fields.length; i++) {
                       
var field = json.fields[i];     
                       
alert(field);
                   
}
               
}
            }
        };
       
$('#asset_form').submit(function() {
           
$(this).ajaxSubmit(AFoptions);
            return
false;
       
});      
   
});
function fnAF_Before(q){
    $("#theIndicator"+q).show();
}
</font>I don't understand why the length of "fields" is being
given as 1, and when I try to view the components of fields, I get an
[object Object] error.
I'd appreciate some insight here.
Thanks,
Bruce
</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/