how to get whole JSON data from webservice at once?
I'm trying to get JSON data from my webservice to display it in a data grid editor (developed with jquery) called Handsontable (
http://handsontable.com/ )
Basically my JSON looks like this:
- [
- ["", "2012", "2013", "2014(YTD)"],
- ["Ferrari", 1460089088.3900001, 1637243070.99, 283566771.55000001],
- ["Alfa Romeo", 1199141138.1900001, 1224624821.1500001, 192307335.49000001],
- ]
What i want to do is passing the whole json from webservice to initialize the variable called myData in my html file at once. I mean without using loops etc - the simples way since i'm very inexperienced in jQuery and i'm little bit confused after all those different things i read on the internet.
Below you can download and/or see my html code:
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <link rel="stylesheet" type="text/css" href="/css/result-light.css">
- <script src="http://warpech.github.io/jquery-handsontable/lib/jquery.min.js"></script>
- <script src="http://warpech.github.io/jquery-handsontable/dist/jquery.handsontable.full.js"></script>
- <link rel="stylesheet" media="screen" href="http://warpech.github.io/jquery-handsontable/dist/jquery.handsontable.full.css">
- <link rel="stylesheet" media="screen" href="http://warpech.github.io/jquery-handsontable/demo/css/samples.css?20140401">
-
- <style type="text/css">
- body {background: white; margin: 20px;}
- h2 {margin: 20px 0;}
- </style>
-
- <script type='text/javascript'>
- $(document).ready(function () {
- var myData = ( [
- ["", "2012", "2013", "2014(YTD)"],
- ["Ferrari", 1460089088.3900001, 1637243070.99, 283566771.55000001],
- ["Alfa Romeo", 1199138.1900001, 1224821.1500001, 1923335.49000001],
- ]);
-
- $('#myTable').handsontable({
- data: myData,
- minSpareRows: 1,
- //colHeaders: true,
- contextMenu: true,
- readOnly: true,
- fixedColumnsLeft: 1
- });
- });
- </script>
- </head>
- <body>
- <div id="myTable" class="handsontable" style="width: 400px; margin-left:auto; margin-right:auto; background-color:silver"></div>
- </body>
- </html>