$('select[name="category_id"]').change(function () {
get_properties($("option:selected", this).val());
});
function get_properties(category_id){
realestate_id = $("input[name=id]").val();
$.ajax({
url: "/api/backend/get_properties",
data: {
category_id: category_id,
realestate_id: realestate_id
},
dataType: 'json',
success: function (data) {
for (i = 0; i < data.length; i++){
var property = data[i];
var line = $('<div class="form__item"><label for="'+property.id+'">'+property.name+'</label></div>');
$.ajax({
url: "/api/backend/get_values",
data: { property_id: property.id },
dataType: 'json',
success: function (data) {
for (i = 0; i < data.length; i++){
var variant = data[i];
var variant_line = $("<div class='form__item'><input type='radio' name='properties["+variant.property_id+"]' class='form__radio' id='"+variant.id+"' class='form__radio'><label for='"+variant.id+"'>"+variant.name+"</label></div>");
variant_line.appenTo(line);
}
}
});
properties.appenTo(line);
}
},
error: function (){
$(properties).html('Ошибка сервера при загрузке параметров');
}
});
}
<select name="category_id">
<option value="0">Первая</option>
<option value="2">Вторая</option>
</select>
<div id="properties"></div>
$data = array("propName_1" => "value1", "propName_2" => "value2");
echo json_encode($data, JSON_FORCE_OBJECT);
var jsonData = $.ajax({
url: "/api/backend/get_properties",
async: false
}).responseText;
jsonData = $.parseJSON(jsonData);
console.log(jsonData.propName_1); // value1