This is an ajax call my browser extenions makes to my web api:
$(document).ready(function () {
$select = $('#brandDropdownList');
$.ajax({
type: "GET",
url: 'http://localhost:44358/api/brands',
dataType: 'JSON',
success:function(data) {
$select.html('');
$.each(data, function(key, val) {
$select.append('<option id="' + val.brand_id + '">' + val.brand_name + '</option>');
})
},
error: function(){
$select.html('<option id="-2">Please try again...</option>');
}
});
This currently calls my API which returns the an JSON array from which I then amend each item to an tag making a drop down. I then have another drop down which will be dependant on the brand_name the user chooses. How can I do another ajax call to my web API that will populate another drop down based on the brand (specifically the brand_id) so that only products of that chosen brand are shown. I have created the web api controller and it I am currently accessing it via my localhost with the URL 'http://localhost:44358/api/products'.