I have code in Controller:

public JsonResult CompanyList(int ProvinceId, int DistrictId)
        {
            var daily = from d in _db.CongTies
                                    where d.MaTinh == ProvinceId || d.MaHuyen == DistrictId
                                    select new { Ten = d.TenCT, DiaChi = d.DiaChi };
            return Json(daily, JsonRequestBehavior.AllowGet);
        }

and in View:

$(document).ready(function () {
    $('#District').change(function () {
        $.getJSON('/Product/CompanyList/' + { ProvinceId: $('#Province').val(), DistrictId: $('#District').val() }, function (data) {
            var items = '<div>Ten - DiaChi</div>';
            $.each(data, function (i, ct) {
                items += "<div>" + ct.Ten + "-" + ct.DiaChi + "</div>";
            });
            $('#ctylist').html(items);
        });
    });
});

but it doesn't work. Please help me! Thanks! :(

Related posts

Recent Viewed