I am currently facing a challenge with creating a method to handle an AJAX GET request from JavaScript. Upon debugging, I have confirmed that the GET response method in the backend is retrieving the correct data. However, I am uncertain about how to effectively return this data to the frontend.
Below is the code I am working with:
[HttpGet]
public ActionResult GetOldEntries()
{
var data = db.Entries.Where(e => e.Date.Month != DateTime.Now.Month);
return data; // How can I properly return the data?
}
Front End:
$.get('/Home/GetOldEntries', function (data) {
console.log(data);
});