dynamcly loaded table from a js file.
dynamcly loaded table from a js file.
Hello,
i have recently found this site, and i thought i would try this for sorting my table.
But i am having an issue with it, and now im pulling my hair out trying to figure it out.
the tables are not getting hooked / found.
i have tried
[code]
$(document).ready(function () {
$("#sortable_table").dataTable({
"sAjaxSource": "include/pagebuild2.js",
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"bJQueryUI": true
"sAjaxDataProp": "buildPlayerTable"
});
});
[/code]
and
[code]
$(document).ready(function() {
$("#sortable_table").dataTable( {
"bProcessing": true,
"sAjaxSource": "include/pagebuild2.js"
} );
} );
[/code]
and
[code]
// POST data to server
$(document).ready( function() {
$("#sortable_table").dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "include/pagebuild2.js",
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
[/code]
to no avail.
what am i doing wrong?
OHH and here is this, from one of the tries.
http://debug.datatables.net/imegaf
and here is a sample of the java formed table output.
[code]
Player
Area
Job
Bazaar Message
Player
Area
Job
Bazaar Message
[/code]
i have recently found this site, and i thought i would try this for sorting my table.
But i am having an issue with it, and now im pulling my hair out trying to figure it out.
the tables are not getting hooked / found.
i have tried
[code]
$(document).ready(function () {
$("#sortable_table").dataTable({
"sAjaxSource": "include/pagebuild2.js",
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"bJQueryUI": true
"sAjaxDataProp": "buildPlayerTable"
});
});
[/code]
and
[code]
$(document).ready(function() {
$("#sortable_table").dataTable( {
"bProcessing": true,
"sAjaxSource": "include/pagebuild2.js"
} );
} );
[/code]
and
[code]
// POST data to server
$(document).ready( function() {
$("#sortable_table").dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "include/pagebuild2.js",
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
[/code]
to no avail.
what am i doing wrong?
OHH and here is this, from one of the tries.
http://debug.datatables.net/imegaf
and here is a sample of the java formed table output.
[code]
Player
Area
Job
Bazaar Message
Player
Area
Job
Bazaar Message
[/code]
This discussion has been closed.
Replies
Have you fully implemented server-side processing, as described here: http://datatables.net/usage/server-side . Also it would be useful if you could link to your page.
Allan
also the way this is working is like this.
a php file gets called from a js file, then that js file gets called from another ( php page. ( the roster.php page is the main page.))
[code]Also it would be useful if you could link to your page.[/code]
[code]
http://sstestserver.zapto.org:22080/roster_sortable_test/roster.php
[/code]
this data only get's populated when there is a person logged into a game server, and as such i will leave my character logged into the game, for the rest of today.
Line 24 - SyntaxError: Expected token '}'
[/code]
That's not going to help :-). You are missing a comma.
Allan
That's not going to help :-). You are missing a comma.
[/code]
ok fixed.
[code]
alert( $("#sortable_table").length );
[/code]
just before you initialise the DataTable please? I don't think it is in the document when initialised.
Allan
[quote]allan said: alert( $("#sortable_table").length );[/quote]
[/code]
done.
And as I am sure you can deduce from the result, there is no #sortable_table when you try to initialise it.
yeap and this has been the issue with other sort-table progs i have tried.
and i cant figure out what is going on, the table is set up properly, and its loading, but any time i try to add a prog to sort that table it cant find it.
any ideas on what i need to do to get it to find the table?
You are currently doing:
1. Try to initialise table
2. Insert table into document
No table library is going to initialise a table which isn't there!
So you need to sort out the order of your code on the page. My guess is that `loadStartPage` is putting the table into the page? That is run at window.onload, which is after the DOM ready which you are using for the table init.
Allan
and thx allen for the help with this.