Ajax lookup freezes on 'Processing...' but json is valid

Ajax lookup freezes on 'Processing...' but json is valid

graedusgraedus Posts: 2Questions: 0Answers: 0
edited November 2009 in General
Hi,

First of all, thank you for a truly awesome plugin. I have had much success with it, but right now I am having a bit of a problem that I can't seem to get around. I am using DataTables in an application -- and recently found that it sticks on 'Processing...' despite the fact that my json is valid. What else might I be doing wrong?

Here is my JS:

[code]
$(function() {
$('table').dataTable( {
"aoColumns": [
null,
null,
null,
null,
null,
{ "bSortable": false, "bSearchable": false }
],
"aaSorting": [[ 1, "asc" ], [ 0, "asc"]],
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "/admin/registrations/ajaxRegistrationLookup/1"
});
});
[/code]

Here is my HTML:

[code]

First Name
Last Name
Age
Gender
Age Group
Options


[/code]

And here is an example of my JSON with personal info obscured (I have my script logging it in a database so I can see it and validate it):

[code]{"sEcho": "1","iTotalRecords": 852,"iTotalDisplayRecords": 852,"aaData": [["DJ","LastName","6","male","5-6 Boys Clinic",""],["Paul","LastName","13","male","11-12 Boys Baseball",""],["George","LastName","11","male","9-10 Boys Baseball",""],["Jamie","LastName","7","female","5-6 Girls Clinic",""],["Amanda","LastName","16","female","14-18 Girls Softball",""],["Brooke","LastName","13","female","11-13 Girls Softball",""],["courtney","LastName","10","female","9-10 Girls Softball",""],["Brendan","LastName","12","male","11-12 Boys Baseball",""],["Alec","LastName","5","male","5-6 Boys Clinic",""],["Anthony","LastName","8","male","7-8 Boys Baseball",""]] }[/code]

What might I be doing wrong? I have read this forum and the documentation fairly extensively but have not been able to figure it out.

Thanks!

Replies

  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    Hi graedus,

    Not that I am an expert or anything, coz im not :-)

    I was having this problem with my server-side processing as-well. The only thing I found to help a little was to delay the server-side filtering response from doing an ajax response every key press. This was causing my server to get a bottle neck of ajax requests which in turn for some reason was returning correct JSON but dataTables only seemed to process the first update and then froze as processing for the rest. So I used the fnSetFilteringDelay plug-in which you can view at - http://datatables.net/plug-ins/api#fnSetFilteringDelay. I used a delay of 1000 ms and found that that greatly improved my response successes.

    Also another thing I do (probably more out of habit) is to use the sName for each column in my initialization and on my JSON return the field order as output by my ajax script in the sColumns return object. Dont know why this helped me but strangely it did.

    This might help you.
    Possibly. LOL

    Regards,
    Izzy
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi guys,

    That's the oddest thing - there used to be a timing condition where the display won't update (1.5 beta 7 or something like that), but that is exactly what the sEcho variable is there to protect against.

    @graedus: I can't see anything wrong with the information that you have provided, so I fear it might require a little bit more debugging... Can you provide a link which will show me the problem? If you don't want to make it public you could sent it to be direct using http://www.datatables.net/contact .

    Regards,
    Allan
  • graedusgraedus Posts: 2Questions: 0Answers: 0
    Thanks to both of you, and Allan, to you especially. It is one thing to produce a wonderful piece of software, it is another to make it available free of charge, and it is another still to offer such great support and assistance with those who use it. Thank you very much!!!

    I found that I was making a ridiculous error. I was logging my JSON output so I could see it but not actually outputing it to the browser. Unbelievable!

    Thank you again for your help. I will let you know if I run into anything else...

    All the best,

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

    heh - easy mistake to make! This one had me a little worried as I couldn't see it at all... Good to hear you got it sorted!

    Regards,
    Allan
This discussion has been closed.