Hi folks,
I don't understand what I'm doing wrong in the following code
(http://temporarius.massey.ac.nz/json_test.htm) where I cannot seem
to "harvest" the returned json string.
The test json string being returned after the form is submitted is:
{"fields": [{"id": "name", "isValid": false, "message": "Username
must be at least 3 characters long"}]}
(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:
$(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();
}
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
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/