I have a dashboard right now that produces graphs and data from the database based on the current year. I am trying to add a dropdownlist of years and then have the graphs in the dashboard change on the year select. I have 2 areas that have to change and I am having issues with getting the variable for the year in the URL. I dont want to post the whole script because it is lengthy. My dropdown works fine, I just cannot use the variable in the string.
This is how it is currently setup:
Inside a $(document).ready(function () { }
SalesByMonth()
var Year = new Date().getFullYear()
$('#year').change(function () {
Year = document.getElementById("year").value;
$("#year").val(" ");
console.log(Year);
});
function SalesByMonth() {
var Year = new Date().getFullYear()
$.ajax({
url: '@Url.Action("GetChartData", "Dashboard", new { Year = "Year" })',
The variable "Year" is not seen by the function. Even if I put it in the function SalesByMonth