2

I'm having trouble getting the footable V3 ajax data loading to work. I'm currently using v3.0.1 and trying to implement the example exactly as specified here:

http://fooplugins.github.io/FooTable/docs/examples/advanced/ajax.html

I have created the specified files columns.json and rows.json containing the same data provided in the example.

I'm initializing the table using:

        $('.table').footable(
        {
            "columns": $.get("locatorApp/columns.json"),
            "rows":  $.get("locatorApp/rows.json")
        });

I'm getting the error:

FooTable: unhandled error thrown during initialization. Error: No columns supplied. at Error (native) at ../footable-standalone-v3.0.1/js/footable.js:2623:16) at ../footable-standalone-v3.0.1/js/footable.js:2662:7)

I know it's finding the files OK as I can induce 404 errors by using incorrect filenames. I tried taking the data from the file and specifying it within the footable initialization object and it works without any problems.

$('.table').footable({
    "columns": [{"name":"col1", "title": "Col 1"},
                {"name":"col2", "title": "Col 2"} ],
    "rows": [{"col1":"abc", "col2":"def"},
                     {"col1":"ghi", "col2":"jkl"}, 
                     {"col1":"ghi", "col2":"jkl"}, 
                     {"col1":"ghi", "col2":"jkl"}, 
                     {"col1":"ghi", "col2":"jkl"}]
});

I'm wondering if I'm not specifying the promises correctly, although they are identical as shown in the above footable example.

Any help is greatly appreciated.

Joe
  • 21
  • 6

2 Answers2

0

I don't know whether you're having issues with cross-scripting requests? If you're developing locally see what appears in the javascript console in the developer options. I had this issue using local json files recently.

Mike Resoli
  • 1,005
  • 3
  • 14
  • 37
0

The problem was that, when reading a file, the promise passed to Footable resolves as a string array instead of an array of JavaScript objects containing row data.

Joe
  • 21
  • 6