Thanks, I am passing in the array via json now and setting datatype to json, per your example as:
{"car_make_id":"3","car_engine_type":"Non-Turbo Petrol"}{"car_make_id":"3","car_engine_type":"Non-Turbo Diesel"}
But my script still refuses to append the select options and values?:
$("select#make").change(function(){
$('#engine').find('option').remove().end(); //clear the engine ddl
var make = $(this).find("option:selected").val(); //Need the value not the text - .Text()
//alert(make);
//do the ajax call
$.ajax({
url:'get-engine.php',
type:'GET',
data:{engine:make},
dataType:'json',
cache:false,
success:function(data){
//var parsedjson = data=JSON.parse(data); //no need if data:type json
$.each(data, function(index, item) {
$("<option/>", {
value: item.car_make_id,
text: item.car_engine_type
}).appendTo("#engine");
});
}
});
});
Can’t seem to find why it will not parse the array?
The JSON structure is horrible so the real problem is to fix your JSON to be logical. Anyways
here’s what you can try with the current one:
jsfiddle: http://jsfiddle.net/DBg2L/1/