JavaScript error: 'iCreate' is null or not an object.

JavaScript error: 'iCreate' is null or not an object.

benwilsonbenwilson Posts: 12Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
Hi,
We are getting this JavaScript error:

'iCreate' is null or not an object.
jquery.dataTables.1.9.3.js
Code: 0
Line: 4500
Char: 7

It only happens in IE 8.0.7600. (Not in IE 8.0.7601).
It only happens on servers that have https enabled.
The page that it happens on has multiple datatables on it.

This prevents the page from being displayed correctly.

Please help.

Replies

  • benwilsonbenwilson Posts: 12Questions: 0Answers: 0
    Here is the initialization script of one of the tables, in case it helps. They are all fairly similar.
    [code]var attestationNonEmployeesTable;
    $(function() {
    attestationNonEmployeesTable = $('#attestationNonEmployeesTable').dataTable({
    'bJQueryUI': true,
    'bAutoWidth': false,
    'bProcessing': true,
    'bDeferRender': true,
    'bSortClasses': false,
    'bStateSave': true,
    'sAjaxSource':'/myapp/home/getAttestationNonEmployeesData',
    'sPaginationType': 'full_numbers',
    'aaSorting':[[8,'asc']],
    'aoColumns': [
    {'bSearchable':false,'bVisible':false},
    {'sClass':'column-1','bSortable':false},
    null,
    null,
    null,
    null,
    null,
    {'sType':'date'},
    {'sType':'date'},
    {'bSearchable':false,'bVisible':false}
    ],
    'fnDrawCallback': function() {
    if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1) {
    $('#attestationNonEmployeesTable_paginate.dataTables_paginate').css('display', 'block');
    } else {
    $('#attestationNonEmployeesTable_paginate.dataTables_paginate').css('display', 'none');
    }
    if(this.fnSettings().fnRecordsDisplay() > 10) {
    $('#attestationNonEmployeesTable_length.dataTables_length').css('display', 'block');
    } else {
    $('#attestationNonEmployeesTable_length.dataTables_length').css('display', 'none');
    }
    },'fnInitComplete': function() {
    var numRows = attestationNonEmployeesTable.fnSettings().fnRecordsTotal();
    $('#attestationNonEmployeesCount').html(numRows);
    if(0 == numRows) {
    $('#attestationNonEmployeesContainer').css('display', 'none');
    $('#attestationNonEmployeesEmpty').css('display', 'block');
    }
    attestationInit();
    }
    });
    });
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Ben,

    That's an interesting one. I wonder if IE is doing something funny with https cookies. Could you possibly open the developer tools for IE or use Firebug Lite and type 'document.cookie' into the console and then paste the result in here so we can see what the cookie looks like?

    Thanks,
    Allan
  • benwilsonbenwilson Posts: 12Questions: 0Answers: 0
    Allan,
    This is the cookie text you asked for:
    [code]"SpryMedia_DataTables_attestationNonEmployeesTable_; tabs-id=tabs-1; SpryMedia_DataTables_activeNonEmployeesTable_=%7B%22iCreate%22%3A1347550718166%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22aaSorting%22%3A%5B%5B7%2C%22asc%22%2C0%5D%5D%2C%22oSearch%22%3A%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%22aoSearchCols%22%3A%5B%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%5D%2C%22abVisCols%22%3A%5Bfalse%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%5D%7D; SpryMedia_DataTables_inactiveNonEmployeesTable_=%7B%22iCreate%22%3A1347550718229%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22aaSorting%22%3A%5B%5B7%2C%22asc%22%2C0%5D%5D%2C%22oSearch%22%3A%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%22aoSearchCols%22%3A%5B%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%5D%2C%22abVisCols%22%3A%5Bfalse%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%2Ctrue%5D%7D; SpryMedia_DataTables_tasksTable_=%7B%22iCreate%22%3A1347550718260%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22aaSorting%22%3A%5B%5B0%2C%22asc%22%2C0%5D%5D%2C%22oSearch%22%3A%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%22aoSearchCols%22%3A%5B%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%5D%2C%22abVisCols%22%3A%5Btrue%5D%7D; SpryMedia_DataTables_sponsoringManagersTable_=%7B%22iCreate%22%3A1347550718291%2C%22iStart%22%3A0%2C%22iEnd%22%3A0%2C%22iLength%22%3A10%2C%22aaSorting%22%3A%5B%5B0%2C%22asc%22%2C0%5D%5D%2C%22oSearch%22%3A%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%22aoSearchCols%22%3A%5B%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%2C%7B%22bCaseInsensitive%22%3Atrue%2C%22sSearch%22%3A%22%22%2C%22bRegex%22%3Afalse%2C%22bSmart%22%3Atrue%7D%5D%2C%22abVisCols%22%3A%5Btrue%2Ctrue%5D%7D; IPCZQX03a36c6c0a=a100ea01a1d7e5f0f0c6a801abdfadc8a782c696; ZNPCQ003-32383800=3ed665de; JSESSIONID=GfjpQR8H3Zv4FyJYQnW8HplQmsxsQp9NpvFbrvDQcTgGFhxtyXv5!-1383801396"[/code]

    Thanks
    -Ben
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Ben,

    Thanks very much for that. I think I've discovered the issue based upon the contents of your cookie - the deletion of old cookies wasn't quite working as it should. I've just committed an update to the code for this issue, and you can get it from the 1.9.4.dev version on the DataTables download page: http://datatables.net/download .

    I've just tried it out with a few cookie test pages I've got here in IE8 and various other browsers, but if you could let me know how you got on with the fix that would be great. I'll be packaging up 1.9.4 final soon(ish) :-)

    Regards,
    Allan
  • benwilsonbenwilson Posts: 12Questions: 0Answers: 0
    Hi Allan,
    Thanks for the fix. I have yet to test it on our server (since that takes more time), but testing locally, it seems that the sorting is not always saved now. As I mentioned, I have multiple datatables, and sorting never saved for all of them. When I watch the cookies in firebug, changing the sort order of a table will make a new cookie appear for that table but make the cookie for another table disappear. I did not have this issue before.

    Thanks!
    -Ben
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    With cookies you can only save 4KiB of data. My demo table of 5 columns takes almost 1KiB, so if you have tables of around 5 columns you can state save 4 of them reliably. If your table has many more columns, then the state saving is of course reduced in capacity. This 4KiB limit is simply the way cookie work and the only way around it is to use something other than cookies(*).

    This blog post details how localStorage can be used to overcome some of these limitations: http://datatables.net/blog/localStorage_for_state_saving . Other options include using Flash or Ajax calls to the server.

    (*) Actually the amount of information in the cookie can be reduced, to fit more in, but fundamentally, cookies are very limiting and are best avoided if possible.

    Allan
  • benwilsonbenwilson Posts: 12Questions: 0Answers: 0
    Thanks for the suggestion. I switched to using localStorage and that fixed the problem. Unfortunately I did not get to test your patch with the cookies on our server (I don't have access to deploy on it myself). 1.9.4 does appear to be working fine though.

    Ben
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Ben,

    Great - thanks for the feedback. Good to hear that localStorage is working well for you. I think at some point I'll put that into DataTables core and the cookies will be a developer defined option, like how localStorage currently is. Possibly in 1.10 in fact.

    Regards,
    Allan
  • benwilsonbenwilson Posts: 12Questions: 0Answers: 0
    In that case, I should point out that I had to include a couple of additional JavaScript files in order to provide compatibility with IE 6 and 7. For localStorage I used https://github.com/wojodesign/local-storage-js and for JSON I used https://github.com/douglascrockford/JSON-js.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Excellent - thanks for the links. I hadn't come across the localStorage shim before, but that's really useful to know about.

    Regards,
    Allan
This discussion has been closed.