1.10 data link broken

1.10 data link broken

tonestones Posts: 7Questions: 0Answers: 0
edited January 2014 in General
Hello, I am trying out 1.10. After getting 1.9 to work fine, and seeing that PDO is now in 1.10 I decided to switch.

I am not getting any data from my database in 1.10.

I am using this new-ish procedure as documented for ajax calls.

[code]$(document).ready(function() {
$('#scheduleTable').DataTable( {
serverSide: true,
ajax: {
url: 'schedule_table.php',
type: 'POST'
}
} );
} );
[/code]

schedule_table.php is basically a replica of your server_processing.php. If I view this file separately I see all the desired data, so my data does get called. However, I don't think my link is there anymore to the HTML side or to Ajax, not sure where it is getting broken. One thing I am confused on the new API, is it .DataTable or .dataTable?

And do you see anything wrong with this? This same setup (except for the changes in the code above) worked in 1.9.

PS - I am using the zip file of 1.10 from GitHub, and not using the 1.9.4 release and just replacing it with a 1.10 nightly build. Is that what i should be doing?

Thank you.

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > schedule_table.php is basically a replica of your server_processing.php

    From 1.10 or 1.9?

    In 1.10 the parameters that DataTables sends to the server have been altered when you use the `ajax` option. If you use `sAjaxSource` the old method is still used for backwards compatibility, and there is a flag that can be used to override completely, but in your configuration above it will be using the new parameters.

    > One thing I am confused on the new API, is it .DataTable or .dataTable?

    I think I'm going to pay for that decision - but couldn't think of a better way. Anyway - it is clearly explained in the new documentation that will be available when 1.10 is released. For the above, it makes no difference - its what is returned that is different `d` gives a jQuery object and `D` gives a DataTables API instance.

    Allan
  • tonestones Posts: 7Questions: 0Answers: 0
    server_processing.php from 1.10. I essentially started fresh with a 1.10 build from GitHub.

    I can see the CSS (actually, I copied your demo_tables.css from 1.9) is being loaded to my table, scheduleTable. But no rows are being populated. My table structure is:

    [code]


    Row1
    Row2


    [/code]

    You see my jQuery call from my first post, and I've proven to myself that loading schedule_tables.php loads all of the table data.

    I can't see what I've done wrong.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    I'd need a link to a test case, which I'd really appreciate, since if there is something broken in 1.10 that I'm not aware of, it needs to be fixed!

    Allan
  • tonestones Posts: 7Questions: 0Answers: 0
    edited January 2014
    All my files are linked correctly (ie I can use Web Developer and see all included scripts and files are loaded)

    I'm not sure what the best way to do that is so here is my live link:


    And here is a small zip file of my php and js files other than DataTables.js:


    I really appreciate the help... It's probably a simple mistake.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    edited January 2014
    Thank you for the link.

    There are a number of Javascript errors on the page:

    > ReferenceError: Can't find variable: require

    and others.

    This is basically because you've included the DataTables build file ( ), not the built file.

    Did you get that file from the DataTablesSrc repo? You really want to be using this file:
    https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js

    Allan
  • tonestones Posts: 7Questions: 0Answers: 0
    edited January 2014
    Brilliant... thank you.

    I don't know why I touch GitHub, I always pull the wrong stuff. If you get the chance can you remove my link in your post?

    Final question: do I need tabletools or any extras for typical column sorting? I'm noticing that is not working as well, and it did work in 1.9.4 with nothing extra as far as I downloaded.

    Thanks again.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > I don't know why I touch GitHub, I always pull the wrong stuff.

    Hehe. The perils of used unreleased software... The new docs and download information should be much clearer on the new site.

    > Final question: do I need tabletools or any extras for typical column sorting?

    No. Sorting is built-in and should work okay. You are using server-side processing, so it is the server that is doing the sorting, not DataTables in this case. So there is something wrong wrong with your server-side script.

    The `draw` count looks wrong to me. There is something not right with the server-side processing script you are using.

    Do you really need SSP? Are you going to have 50'000+ rows?

    Allan
  • tonestones Posts: 7Questions: 0Answers: 0
    It's definitely possible, if you mean 50,000 rows within one table... I am mostly concerned about security though. And I want to be able to add/edit/delete.

    I cannot see anything wrong in my server side script. Do you mean my php script or js script that includes the #table definition?

    The only thing I notice and I'm not sure if it's a concern, is in my js script I have:

    [code]ajax: {
    url: 'schedule_table.php',
    type: 'POST'
    }[/code]

    And in my PHP I have

    [code]
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
    [/code]

    The difference between GET and POST. Not sure if it matters.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Looks like you are using GET parameters ( `$_GET` ) but POSTing them. Is there a reason for that?

    Here is an example of an SSP script using POST:
    https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/post.php

    Allan
  • tonestones Posts: 7Questions: 0Answers: 0
    Hrm, I figured my SSP script is GETing the data, and the Ajax is posting to the HTML? hehe... I may have some holes in my knowledge.

    Anyway, that worked. Thank you for all this help. I also really appreciate all the explanations you have for your API. It really helps novice programmers like me!
This discussion has been closed.