//in view
$('#drpdwn1').bind('change', function ()
{
var id = $('#drpdwn1').val();
if (id != "" && id != null && id != undefined)
{
$.ajax({
url: '/controller/action/',
type: 'POST',
contentType: 'application/json;charset=utf-8',
data: '{"id":"' + id + '"}',
success: function (response)
{
var drpdwn2 = $('#drpdwn2');
drpdwn2.empty();
drpdwn2.append('<option value="">--Select--</option>');
$.each(response, function (index, month)
{
drpdwn2.append($('<option />',
{
value: month.intValue,
text: month.stringValue
}));
}
});
});
In controller action
var result = from c in DB.tableName
where c.col_name == Id
select new IntStringPair
{
intValue = c.Id,
stringValue = c.name
};
return Json(result , JsonRequestBehavior.AllowGet);