I need to pass a few parameters from view to Controller using JavaScript AJAX.
Following is my code for the JavaScript:
<script>
$(document).ready(function () {
$('#PaidMonth').on('change', function () {
var deviceid = $('#PaidMonth').val();
alert(deviceid);
$.ajax({
type: 'GET',
data: { PaidMonth: deviceid },
url: 'http://localhost:8089/HRM/PaidSalary/id?EmpName',
dataType: 'json',
success: function (data) {
console.log(JSON.stringify(data))
vehicle = $("#MonthOfSalary").val();
console.log(vehicle);
},
async: true // make it true if you want to make an async call.
});
});
});
</script>
I need to pass the data to controller:
public ActionResult PaidSalary(Int64 id, String EmpName, DateTime? PaidMonth)
I need id, Empname, PaidMonth which I will be passing from the View.
Also, please don't mark the question as Duplicate as I am not able to find appropriate result.
PaidMonthas string and convert it in to DateTime in controller menthod PaidSalary