mData Unknown Parameter using Server side Javascript Objects

mData Unknown Parameter using Server side Javascript Objects

jimbob72jimbob72 Posts: 49Questions: 0Answers: 0
edited May 2013 in DataTables 1.9
Here is a link that should show one row. But I am getting an unknown parameter error for the mData column titles.

http://www.doremus.info/HQ/creatives?job_num=301722

The debug is at http://debug.datatables.net/ezayap

As far as I can tell the JSON is correctly formatted (having checked on jsonlint) and the columns are not null. Is the JSON wrong in some way?

Any help much appreciated as always.
James

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Hi James,

    Thanks fir the links. The error you are seeing means that there is no hq_creative.id parameter defined for the rows data source object.

    The dot in the mData parameter you are using means that DataTables is expecting an object - the dot is a special option. In DataTables 1.10 you can escape the dot to have it treated as a regular for, but this is not available in 1.9-.

    You could try the 1.10 wip code, but it's not ready for production use yet!

    are you able to change the json format to change the dot to a dash perhaps?

    Regards,
    Allan
  • jimbob72jimbob72 Posts: 49Questions: 0Answers: 0
    edited May 2013
    Thanks Allan

    But my server response includes hq_creatives.id as a value in the JSON:

    {"sEcho":1,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[{"hq_creatives.id":1,"hq_publications.name":"FT","hq_creatives.meta":{"width":"340","height":"175","bleed":"0","description":"Inner full-page"},"hq_types.name":"Magazine","hq_job_cre.job_num":301722,"hq_job_cre.cre_id":1,"hq_creatives.publication":1}]}

    'id' is a column in the 'hq_creatives' table.

    Should the JSON be in a different format?

    James
  • jimbob72jimbob72 Posts: 49Questions: 0Answers: 0
    By the way - I removed the outer '(...)' brackets from the JSON response as it was making it hang on 'Processing...'. If I put them back, then it hangs but I don't get the error.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > But my server response includes hq_creatives.id as a value in the JSON

    Yes indeed, but as I say, DataTables treats the dot like Javascript does - i.e. it expects an object, not a dot.

    So it would expect data in the structure:

    [code]
    {
    "hq_creatives": { "id": 1 },
    ...
    }
    [/code]

    Are you able to change the json format to change the dot to a dash? Otherwise the data functions for DataTables 1.10 could be back ported, but they are fairly core to DataTables so there could potentially be unforeseen side effects.

    Regards,
    Allan
  • jimbob72jimbob72 Posts: 49Questions: 0Answers: 0
    Thanks Allan. That solved the problem. Just for the record I amended the server-side script to the following:
    [code]
    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
    $row = array();
    for ( $i=0 ; $i
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Excellent to hear.

    In DataTables 1.10 you'll be able to use `"hq_creatives`.id"` to resolve this issue, and that is available in git already, but I'd wait for the beta at least... :-)

    Regards,
    Allan
This discussion has been closed.