my json is not getting parsed through query.
Hi
My json is not getting available. both are in same folder. Please tell where i am wrong. I am pasting both html and json here:
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Table</title>
- <script type="text/javascript" src="./jquery-1.8.2.js"></script>
- <script type="text/javascript" src="./table.json"></script>
- <script type="text/javascript">
- $.getJSON('table.json', function(data){
- alert(data);
- $(data.ItemisedBill).each(function(index,element){
- $('#tableData').append('<tr><td><input type="checkbox" name="chk"/></td><td>1</td><td><input type="text"/></td>');
- });
-
- });
- </script>
- </head>
- <body>
- <input type="button" value="Add Row" id="addRow" />
- <input type="button" value="Delete Row" id="deleteRow" />
- <table id="tableData" width="550px" border="1">
- <tr>
- <th>CheckBox</th>
- <th>Serial No.</th>
- <th>Item</th>
- <th>Price</th>
- <th>Quantity</th>
- <th>SubTotal</th>
- </tr>
- </table>
- </body>
- </html>
Json:
- var ItemisedBill= [{
- "item":"name1",
- "price":"20",
- "quantity":2
- },
- {
- "item":"name2",
- "price":"30",
- "quantity":1
- },
- {
- "item":"name3",
- "price":"40",
- "quantity":3
- },
- {
- "item":"name4",
- "price":"14",
- "quantity":1
- },
- {
- "item":"name5",
- "price":"44",
- "quantity":4
- }
- ];
Thanks!