Ajax, Few Problems

Ajax, Few Problems

FogestFogest Posts: 7Questions: 1Answers: 0
edited December 2012 in General
Here is a test page for you:
http://fogest.com/test/
As you see, it throws an error, and simply does not work.

JS:
[code]
$(document).ready(function() {
$('#trades').dataTable( {
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"bProcessing": true,
"bServerSide": true,
"aoColumns": [
{ "mData": "id" },
{ "mData": "Minecraft_Username" },
{ "mData": "Block_Name" },
{ "mData": "Quantity" },
{ "mData": "Cost" },
{ "mData": "Trade_Status" },
],
"sAjaxDataProp": "aaData",
"sAjaxSource": "test.php"
} );
} );
[/code]

And the test.php source:
[code]
<?php
$tableName = "mctrade_trades";
$result = mysql_query("SELECT `id`, `Minecraft_Username`, `Block_Name`, `Quantity`, `Cost`, `Trade_Status` FROM $tableName");

$data = array();
while ( $row = mysql_fetch_assoc($result) )
{
$data[] = $row;
$output['aaData'][] = $row;
}
//$output['aaData'][] = $row;
header("Content-type: application/json");
echo json_encode( $output );

?>
[/code]

Tables:
[code]



Trade ID
Minecraft Username
Item
Quantity
Price
Trade Status(opened/closed)





[/code]

Output of the test.php:
http://fogest.com/test/test.php

What am I doing wrong?

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You've enabled server-side processing, but your data source doesn't implement server-side processing. If you want to use server-side processing you need to implement the protocol described here: http://datatables.net/usage/server-side

    For that few rows though, I'd suggest you don't use server-side processing - there is no need.

    Allan
This discussion has been closed.