[eluser]richthegeek[/eluser]
well AJAX implies XML - therefore changing that structure into XML using this function:
Code:
function array_to_xml( $input, $level) {
$pre = "\n".str_repeat(" ",($level));
foreach( $input as $key=>$child ) {
if( is_array( $child ) ) {
$output .= $pre."<".$key.">".array_to_xml($child, $level+1).$pre."</".$key.">";
} else {
$output .= $pre."<".$key.">".$child."</".$key.">";
}
}
return $output;
}
Then with jQuery you can do (remember to return as Content-type:text/xml):
Code:
function( data ) {
$(data).children().each( function() {
var group_id = $(this).find("group_id").html();
var subtype_id = $(this).find("subtype_id").html();
var xname = $(this).find("name").html();
// do any append() etc here
})
}
Note, I used "xname" because "name" is semi-restricted and can cause cock-ups in various browsers.