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; ?>)" >

in javascript

				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;
				} // /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


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