I am very new to web services and I have just recently started developing a service that receives data from a raspberry pi. All the data sent from the Raspberry Pi is stored inside the Microsoft SQL server, which I have established a connection with my web service. Right now, I am able to view the data when I click on a hyperlink, but comes out in a notepad in json format. The following is my code for the controller:
namespace HelloWorld.Controllers
{
public class SecondlyReadingDatasController : ApiController
{
private cloudsqlEntities db = new cloudsqlEntities();
// GET: api/SecondlyReadingDatas
public IQueryable<SecondlyReading> GetSecondlyReadings()
{
SecondlyReading sec = db.SecondlyReadings.First();
return db.SecondlyReadings;
}
Below is an image of the data that I am trying to retrieve:

I have read up online that using Ajax and Highcharts can be used to display data, however, I am really confused.
My main questions are:
- Where do I implement the code for the Ajax feature? In the Index.cshtml or_Layout.cshtml?
- Do I need to add anything in my model or controller?
- Do I need to install any packages or libraries? I have installed DotNet.HighCharts already
I have tried placing the following code in the _Layout.cshtml, however, I am not getting anything:
<script type="text/javascript">
$.ajax({
url: 'http://localhost/TestWebsite/api/SecondlyReadingDatas',
success: function(singleSeries) {
Highcharts.chart('container', {
series: [singleSeries]
});
}
});
</script>
I am not sure if this is the complete set of code that is required only. I have tried looking at the following links, but I am having a hard time understanding as this is my first time working on Ajax. Would appreciate any assistance
Referenced links:
http://www.c-sharpcorner.com/UploadFile/1f3f2a/charting-in-mvc/
https://learn.microsoft.com/en-us/aspnet/web-pages/overview/data/7-displaying-data-in-a-chart
https://www.codeproject.com/Articles/820349/Highcharts-in-asp-net-using-jquery-ajax Load data into Highcharts with Ajax
https://csharptrenches.wordpress.com/2013/08/21/how-to-use-highcharts-js-with-asp-net-mvc-4/