First try of "Join Tables Example" with Editor -> DataTables warning: table id=users - Ajax error.
First try of "Join Tables Example" with Editor -> DataTables warning: table id=users - Ajax error.
![olivervogt](https://secure.gravatar.com/avatar/e4497ae90bdb546da5130be83a602820/?default=https%3A%2F%2Fvanillicon.com%2Fe4497ae90bdb546da5130be83a602820_200.png&rating=g&size=120)
Hi - I have just generated (or actually not) my first "Join Tables" example page on my own test server with the editor but got an Ajax error message. I am not sure if this is due to the code or another server setting. Here is what I did...
- Generate a simple set of 'Editor data tables' zipped files with the Generator online (same table structure as the online "join tables" example online) - there are actually two sets of zipped files - one for each table: 1x users + 1x sites
- Download and explore all files, in particular, the following three: myTableName.html -> myTableName.js -> myTableName.php
- Unzip both sets of "Generator Files" into one directory + edit MySQL credentials in config.php + upload to my webserver and run the code
- ...so far so good... The Editor works well!
- Next ... modify the autogenerated code based on the online example https://editor.datatables.net/examples/simple/join.html
- do nothing with the root directory file myTableName.html
- as referenced in the HTML file above in directory js/myTableName.js - copy paste js code from online example
- as references in the JS file above in directory php/myTableName.php - copy-paste php code from online example
- as references in the PHP file above in directory sql/myTableName.sql - do nothing ... code to run only once...
The only changes are:
- different table name "dtusers" instead of "users" in the original online example
- modified the "sites" column in the "users" table to be "int" in phpmyadmin (this was "text" when auto generated)
- here are all the files: https://drive.google.com/file/d/1BaUxtupJuvIZLPKNnN_1YuVQaYm_0JUk/view?usp=sharing
The error message is as follows:
DataTables warning: table id=dtusers - Ajax error. For more information about this error, please see http://datatables.net/tn/7
What would be the issue here?
Thanks,
Oliver
This question has an accepted answers - jump to answer
Answers
Did you follow the diagnostic steps in the link provided in the error message? That would be the place to start debugging.
thanks for the quick reply - doh!
there are two references to the file "myTableName.php" in file "myTableName.js" - one was changed and one was not... all good now ;-)
Thanks,
Oliver
Hello, one other point from this... let's say I add a column 'description' to the sites table. Is there a way to only display the column 'description' on the joined user table?
e.g. display two additional columns (1) site name (2) site description.
Thanks,
Oliver
Sure - if you consider this example it only shows the site name column from the joined table, not anything else. You just need to include only the columns that you need in the fields array (assuming you are using our PHP libraries).
Allan
Thanks, both. All works well. For completeness - here is the PHP snippet if you like to display another column from a joined table e.g. notes related to the site in this case ...
here is the js snippet:
{ data: "sites.name" },
{ data: "sites.notes" }
Thanks,
Oliver