现在JSON数据已存储在ajax中的变量“msg”中。我只能在页面中提醒(msg)。但我想把它放入数据表或以任何合适的方式查看ajax或js中的列的数据。将json转换为jQuery数据表中的ajax?
这里是JSON类型:
{ "aaData": [ { "ID": "1", "FESTIVAL": "Antipodes Festival", "SUBURB": "Lonsdale Street, Melbourne", "POSTCODE": "3000", "WEBSITE": "http://www.antipodesfestival.com.au/", "DESCRIPTION": "The greek precinct in melbourne cbd will transform into a huge, free street festival with the hosting of the antipodes lonsdale street festival which will hold sway from 14 february 2015 to 15 february 2015." }, { "ID": "5", "FESTIVAL": "Boite Singers Festival", "SUBURB": "Victoria", "POSTCODE": "3000", "WEBSITE": "http://boite.com.au/index.php", "DESCRIPTION": "The boite singers festival brings you four days of vocal inspiration and sheer fun on the second weekend of january each year." } ] }
它给出了一个错误:0x800a138f - JavaScript运行时错误:无法获取未定义或空引用的属性“长度”。发生在myjson.aaData.length中。顺便说一句,我已经在页面中添加了参考,我不知道为什么。 –
我试过你的代码,它的工作原理。唯一的问题是我的数据存储在变量“msg”中,每当我从sql server获取数据时它都会更改(但格式相同)。我不能var myjson = {...};我用msg.aaData.length,它会给上面的错误。你能告诉我如何解决它吗? –
它在创建dataTable()时会产生错误。 –