I have ajax code that gets data from a radio button.
$("input[name='SelectedCG']").on('change', function () {
$.ajax({
url: '@Url.Action("FilterReports", "Reports")',
data: { cgName: $("input[name='SelectedCG']:checked").val() },
type: 'POST',
success: function (data) {
$('#reportTable').html(data);
$('#reportTable').show();
},
error: function(xhr, status, error)
{
alert(xhr.responseText);
}
})
});
I want to bind this data to a submit button which can pass this information to a method in a controller.
<input type="submit" value="Export" class="btn btn-primary btn-large" onclick="location.href='@Url.Action("Export", "Reports")'">
Any help would be appreciated!
Export()method?Export()method (just as you did in theFilterReports()method.FormMethod.Getor else you need to use javascript to generate the url based on the selected radio button value.