Server side Datatables not working with Classic ASP
Server side Datatables not working with Classic ASP
I have a table with 120.000 record. I try an example for server-side pagination. I looked for a sample written in ASP and I found it But it is not working. I am getting "DataTables warning: table id=example - Invalid JSON response" error.
My script codes:
$(document).ready(function() {
$('#example').DataTable( {
processing: true,
serverSide: true,
ajax: {
url: "musteri_list_load.asp",
dataType: "json"
}
} );
} );
musteri_list_load.asp codes:
If rs.RecordCount > 0 Then
output = "{ ""data"":["
Do While Not rs.EOF
output = output & "{""id"":""" & rs("ID") & """,""engine"":""" & rs("engine") & """},"
rs.MoveNext
Loop
output=Left(output,Len(output)-1)
output = output & "]}"
End If
response.write output
And musteri_list_load.asp output:
{ "data":[{"id":"1","engine":"Trident"},{"id":"2","engine":"Trident"},{"id":"3","engine":"Trident"},{"id":"4","engine":"Trident"},{"id":"5","engine":"Trident"},{"id":"6","engine":"Trident"},{"id":"7","engine":"Gecko"},{"id":"8","engine":"Gecko"},{"id":"9","engine":"Gecko"},{"id":"10","engine":"Gecko"},{"id":"11","engine":"Gecko"},{"id":"12","engine":"Gecko"},{"id":"13","engine":"Gecko"},{"id":"14","engine":"Gecko"},{"id":"15","engine":"Gecko"},{"id":"16","engine":"Gecko"},{"id":"17","engine":"Gecko"},{"id":"18","engine":"Gecko"},{"id":"19","engine":"Gecko"},{"id":"20","engine":"Gecko"},{"id":"21","engine":"Gecko"},{"id":"22","engine":"Gecko"},{"id":"23","engine":"Gecko"},{"id":"24","engine":"Gecko"},{"id":"25","engine":"Gecko"},{"id":"26","engine":"Gecko"},{"id":"27","engine":"Webkit"},{"id":"28","engine":"Webkit"},{"id":"29","engine":"Webkit"},{"id":"30","engine":"Webkit"},{"id":"31","engine":"Webkit"},{"id":"32","engine":"Webkit"},{"id":"33","engine":"Webkit"}]}
I valideted this output this link and it is OK.
I don't know what to do. Help me please.
Thanks for your helps...
This question has an accepted answers - jump to answer
Answers
What does your HTML look like for your table?
My HMTL page looks like this.
That's helpful. Your data is not in JSON format. It is an array.
Compare that to the data format here
http://datatables.net/examples/ajax/simple.html
I tried this, but it didn't work: (I validated in JSONLint)
I am using asp codes below for create this:
What you have is an JSON object with an array in it. That is similar to the example I linked to. Try removing the datatype option as shown in line 7 of your original post.
you have to make something like this:
@ThomD, it didn't fix when i removed datatype. But I am sure that the fault is in this section. But I don't know where.
@alexvremja your codes are getting similar output to my codes. What is your
$(document).ready(function()
codes?Thanks
but from what I have understood "your" problem is on "":
You have to encapsulate every fieldName and FieldValue inside "":
to be more clear:
has to be
@alexvremja your solution is working. It is worked when I changed output codes as you noted.
Thank you.
:-)
I have a new problem now. My paging and searching system is not working.
My script codes:
My musteri_list_load.asp codes
Codes are working in this link and you can look at my error.
Thanks.
no idea about paging.. never used
but concerning filtering..
what means this?
and also this
is quite unusual.. do you have html tags into a database field?
in any case you are searching for the html string and not the content of sSearch..
for filtering I think you should use a different approach: something like:
But I think we are OT.. this is ASP issue not DT
good luck!
Oh ok. Thanks for your helps...
But if I know how to get search variable to my asp page, I will solve my problem. I only don't know selectbox names, textbox names and page number form elements names. Can I determine them in my script codes below?
These links were automatically added by forum editor.
My real codes:
And my script is working perfect when I make serverside: false.
But I need serverside for over 120.000 records.
Is there anyone who will help me for my problem pls?
you have to check which parameters does the ajax query pass to the new page:
just need click right on inspect element and check the parameters of call in network..