Notice: Undefined index: sEcho (sEcho is passed in request though)

Notice: Undefined index: sEcho (sEcho is passed in request though)

FogestFogest Posts: 7Questions: 1Answers: 0
edited April 2013 in DataTables 1.9
Upon trying to sort or filter data from a Datatable using the server_side processing script on the example page, I am given the following error:

[quote]Notice: Undefined index: sEcho[/quote]

And the JSON output returned is:
[quote]{"sEcho":0,"iTotalRecords":"2","iTotalDisplayRecords":"2","aaData":[["DC2610","3"],["DC2611","3"]]}[/quote]

This does not make sense to me, because according to the network tab of Chrome, when I try to sort the data a request is handed off with sEcho being equal to 2 as seen below:

[quote]http://localhost/people-app/products/auxRoom.php?sEcho=2&sColumns=room%2Ccapacity&iDisplayStart=0&iDisplayLength=25&sSearch=&iSortCol_0=1&sSortDir_0=asc&iSortingCols=1&ajax=products&visibleColumns=0%2C1 [/quote]

The above is made in the form of a GET request. If it matters I am using the Yii framework, though I don't think that is related. I am using the exact code from the server side scripting example, with the MySQL info changed of course (including columns).

Any reason why this may not be working?


Edit:
I am using Datatables and here are the settings that should be being used currently:
[code]
$.fn.eDataTables.defaults = {
jqxhr: null,
ajaxUpdate: [],
pagerClass: 'pager',
loadingClass: 'loading',
filterClass: 'filters',
tableClass: 'items',
selectableRows: 1,
editableSelectsRow: true,
relatedOnlyOption: false,

ajaxOpts: {},

bProcessing: true,
bServerSide: true,
bStateSave: false,
bAutoWidth: false,
bJQueryUI: true,
sPaginationType: "full_numbers",
//aaSorting: [[0, "asc"]],
iDisplayLength: 25,
editable: {
string: {},
integer: {},
boolean: {}
},
buttons: {},
filterForm: null,
filterSerializeCallback: function(f){return f.serializeArray();}
};
[/code]

Ajax call is made later.

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Looks to me you should just be able to use `$_GET['sEcho']` - I'm not sure why that wouldn't work if sEcho is in the GET parameter list as you show.

    Allan
  • FogestFogest Posts: 7Questions: 1Answers: 0
    Making the exact get call to check the page I am actually getting a different error:

    Notice: Undefined index: bSortable_1 in C:\wamp\www\people-app\products\auxRoom.php on line 60

    Any idea what may be wrong?
  • FogestFogest Posts: 7Questions: 1Answers: 0
    When trying to go to the next page rather than sorting by column I receive no error but it gets stuck on processing and content therefore is not updated. Here is the response:
    [quote]{"sEcho":2,"iTotalRecords":"30","iTotalDisplayRecords":"30","aaData":[["DC2635","13"],["DC2636","14"],["DC2637","14"],["DC2638","15"],["DC2639","15"]]} [/quote]

    I also receive this console error:
    [quote] Uncaught TypeError: Cannot read property 'length' of undefined [/quote]
  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    What do you mean 'making the exact get call'? If its a different error, it must be a different call I think.

    Can you link me to the page please, I'm not exactly sure what is going wrong.

    Allan
This discussion has been closed.