Valid JSON in Text file not loading and no error messages

Valid JSON in Text file not loading and no error messages

artaylorartaylor Posts: 10Questions: 0Answers: 0
edited October 2013 in DataTables 1.9
I am trying to duplicate the objects.html example using my own data. The text file I am trying to load has been validated at jsonlint.com.
When I use the objects.txt file it works, but when I use my file it displays nothing and there are no errors.

I have been staring at the code for hours and my eyes are crossing. Here is the file:

[code]
{ "aaData": [
{
"id": "1",
"title": "James Deen Interview",
"slug": "james-deen-interview",
"subtitle": "The much anticipated interview with James Deen.",
"description": "James Deen opens up about his early life, porn career, and new found mainstream celebrity.",
"episode": "1",
"publish_date": "2013-01-15 08:23:05",
"filename": "wr-podcast-e001-20130113.mp3",
"duration": "576000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "2",
"title": "Justin Donaldson",
"slug": "justin-donaldson",
"subtitle": "Interview with Justin Donaldson.",
"description": "Justin Donaldson of 'Funny or Die', 'Reno 911' and the UCB Theatre talks about his comedy career and more.",
"episode": "2",
"publish_date": "2013-01-31 03:23:05",
"filename": "wr-podcast-e002-20130131.mp3",
"duration": "132164",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "3",
"title": "Rapper Jensen Karp",
"slug": "rapper-jensen-karp",
"subtitle": "Interview with Jensen Karp.",
"description": "Jensen Karp aka rapper Hot Karl, owner of 'Gallery 1988' talks about getting a million dollar record deal, the pop culture art scene, and makes a big announcement!",
"episode": "3",
"publish_date": "2013-02-07 03:23:05",
"filename": "wr-podcast-e003-20130207.mp3",
"duration": "142948",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "4",
"title": "Valentines Day with James Deen",
"slug": "valentines-day-with-james-deen",
"subtitle": "James Deen co-hosts a very special Valentine's Day episode.",
"description": "James Deen, Lee Roy Myers, and Seth's Beard talk about all the things they love in honor of Valentine's Day.",
"episode": "4",
"publish_date": "2013-02-14 03:23:05",
"filename": "wr-podcast-e004-20130214.mp3",
"duration": "739000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "5",
"title": "Bryan Valderrama",
"slug": "bryan-valderrama",
"subtitle": "Interview with Bryan Valderrama",
"description": "Lee Roy and Seth's Beard pitch a Catfish porn parody to Bryan Valderrama, casting director of MTV's 'Catfish', and talk about his reality TV career.",
"episode": "5",
"publish_date": "2013-03-12 04:23:05",
"filename": "wr-podcast-e005-2013-0312.mp3",
"duration": "526000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "6",
"title": "Jake Weisman and Eli Olsberg",
"slug": "jake-weisman-and-eli-olsberg",
"subtitle": "Conversation with comedians Jake Weisman and Eli Olsberg",
"description": "Comedians Jake Weisman and Eli Olsberg talk about comedy, hecklers, porn and genocide (we have no idea how our conversation got there either. But it did).",
"episode": "6",
"publish_date": "2013-03-19 04:23:05",
"filename": "wr-podcast-e006-2013-0319.mp3",
"duration": "714000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "7",
"title": "Alan Baugh",
"slug": "alan-baugh",
"subtitle": "Interview with Alan Baugh",
"description": "Alan Baugh, star of 'Birdemic' and 'Birdemic 2', talks about killer birds, angry directors, and his other amazing experiences on set.",
"episode": "7",
"publish_date": "2013-03-26 04:23:05",
"filename": "wr-podcast-e007-2013-0326.mp3",
"duration": "357000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "8",
"title": "Danko Jones",
"slug": "danko-jones",
"subtitle": "Chatting with rockstar Danko Jones",
"description": "Rockstar Danko Jones chats with us outside the House of Blues in Hollywood about life, music and Canada.",
"episode": "8",
"publish_date": "2013-04-06 08:45:00",
"filename": "wr-podcast-e008-2013-0406.mp3",
"duration": "498000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "9",
"title": "Kevin Tong",
"slug": "kevin-tong",
"subtitle": "Interview with artist Kevin Tong",
"description": "Artist Kevin Tong talks about his career and his love of Paul Verhoeven movies.",
"episode": "9",
"publish_date": "2013-04-16 08:45:00",
"filename": "wr-podcast-ep09_2013-0416.mp3",
"duration": "845000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "10",
"title": "Rask Opticon",
"slug": "rask-opticon",
"subtitle": "A talk with artist Rask Opticon",
"description": "Artist Rask Opticon talks about Grafitti Art, Vinyl Toys, and Super Mario.",
"episode": "10",
"publish_date": "2013-04-26 08:45:00",
"filename": "wr-podcast-ep10_2013-0426.mp3",
"duration": "690000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
},
{
"id": "11",
"title": "James Deen - 'The Canyons'",
"slug": "james-deen-the-canyons",
"subtitle": "James Deen discusses his movie 'The Canyons'",
"description": "James Deen gives us the scoop on Lindsay Lohan, 'The Canyons' and teen mom Farrah Abraham.",
"episode": "11",
"publish_date": "2013-05-06 08:45:00",
"filename": "wr-podcast-ep11_2013-0506.mp3",
"duration": "1039000",
"listens": "0",
"votes_up": "0",
"votes_down": "0"
}
] }
[/code]

I am new to Datatables so any and all help is appreciated. This JSON was generated by Laravel 4.

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Please link to a test page so we can see how you are using DataTables, what the problem is and be able to suggest a way of resolving it.

    Allan
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    Hi Allan,

    www.anthonyrtaylor.com/dev/dt/podcasts.html -- trys to load podcasts.txt in the same folder.

    Also, a simplified objects.html which loads objects.txt is in the folder. This is what I based the podcasts.html file on. It works, so I have to assume it is something in the podcasts.txt JSON file that is the issue but I cannot find it.

    Thanks for the assist.
    Anthony
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Hi Anthony,

    Thanks for the link. You're aoColumns definition has 12 columns in it, but your HTML has only 5 columns. Thus a Javascript error is occurring since DataTables is expecting to find columns 6-12.

    Allan
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    Hi Allan,

    Thanks. The source file has the 12 columns, but I only want to display the subset. One of the ideas I tried was to use "bVisible":false for the columns that I did not want to display. That causes the same issue. I have put them back in and uploaded a new podcasts.html file. How do I limit the number of columns that DT will look at?

    Anthony

    P.S. Congratulations on your expanded family!
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Thanks very much :-)

    Have just five visible columns in your table if you want, but you need to have the same number of header cells as columns. DataTables will remove the columns from the DOM that are hidden. If you don't want them at all, just don't put them into your aoColumns :-)

    Allan
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    Hi Allan,

    Thanks. Just so I understand: I need to have the same number of table headers as columns in aoColumns. Now, as I understand it, aoColumns must have an entry for each column in the data. So, I have a couple of options:
    1. use null in aoColumns for the columns I don't want to read (or aoColumnDefs)
    2. Add a table header for each column and use the bVisible on the columns not to show.

    I will try those but if I have missed anything let me know.

    Cheers Dad!
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    If you want only 5 columns, then you only need 5 columns in your aoColumns. The key point is that aoColumns and the HTML must match.

    Allan
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    I thought the aoColumns must match the input file (which has 12 columns)...
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    No - you've got objects there. If you don't want to use information from the object, just don't :-)

    Allan
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    Hi Allan,

    Pardon my denseness... Is it because I am using the mData option so it knows what field to extract from the object?

    I have a lot of work to do with DT so I want to make sure I understand the basics so I don't have to ask newbie questions all the time.

    Thanks for all the help.
    Anthony
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    > Is it because I am using the mData option so it knows what field to extract from the object?

    Yes! You can actually do that with arrays as well - if you don't specify mData then it is automatically set to the same as the column index, but you could set it to some other index if you wanted... Its just that its a whole lot easier to understand with objects!

    Allan
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    Thanks.

    I have it working now. The data is showing!

    However, when I added the columnFilter() plugin I run into some issues:
    1. The "processing" dialog stays visible
    2. The footer shows "showing 0 of 0"
    3. The {"type": "select"} for the Title is empty.

    I have updated the file on www.anthonyrtaylor.com/dev/dt/podcasts.html

    Probably something really simple again.

    Anthony

    P.S. Let me know if this is not the correct place to ask this.
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Error on the console:

    > TypeError: 'undefined' is not an object (evaluating 'sValue.length')

    Which is coming from the column filter plug-in. I'm afraid that particular plug-in is not part of the DataTables project - its third party software, and I don't really know much about it, so I can't offer much help on it. Sorry!

    Allan
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    Hi Allan,

    I appreciate the response. I was not sure it was something you would be able to help with.

    Regards,
    Anthony
  • artaylorartaylor Posts: 10Questions: 0Answers: 0
    Hi Allan,

    I appreciate the response. I was not sure it was something you would be able to help with.

    Regards,
    Anthony
This discussion has been closed.