How I can display dropdown menu list based on my JSON response object?

I am trying to display a dropdown list based on JSON response object, How I can set it for the following code?

in html

<select class="form-control" name="productCategories[]" id="productCategories<?php echo $x; ?>" onchange="getProductData(<?php echo $x; ?>)" >
			  					
</select>

in javascript

$.ajax({
				url: 'php_action/fetchDropdownProductData.php',
				type: 'post',
				data: {brandId : brandId},
				dataType: 'json',
				success:function(response) { 
					
			var html = '<option value="">Select Sub Category</option>';
            html += response;
            $("#productCategories"+row).html(html);
					
					
				} // /success
			});

What I would do is a console.log(response) to see what you are getting back and I do believe you are going to have to parse the data that you are getting back.

@Strider64 here is the log response

[{“categories_id”:“1”,“categories_name”:“Monitor”},{“categories_id”:“3”,“categories_name”:“Scanner”}]

Is this data coming from your own database? If so, there is no reason to get the data as JSON.

Where is the source data coming from?

@benanamen, yes it is from my own database… for dependent drop down menu–> I am using Ajax and JSON.

Sponsor our Newsletter | Privacy Policy | Terms of Service