I want to bind drop dawn list using jquery depends on another ddl i am using jquery with mvc and here is the code i am using :
public IList<Categories> GetProductCategories(int ProductID, int Inst)
{
//items is a list get it some way no need for details
return items;
}
}
and here is the jquery code :
$(document).ready(function () {
$('#ddlProductType').change(function () {
var x = $('#ddlInstallation').val();
$.ajax({
type: 'POST',
url: '/Home/GetProductCategories',
data: { ProductID: $(this).val(), Inst: x },
success: function (data) {
var markup = '';
for (var x = 0; x < data.length; x++) {
markup += "<option value='" + data[x].Value + "'>" + data[x].Text + "</option>";
}
$('#ddlCategory').html(markup).show();
}
});
});
)};
any help 🙂
I figured out the solution First all I need is not to use it as a function you can do the following :
and there is no errors in your jquery code just try