using sAjaxSource with "bServerSide": true
using sAjaxSource with "bServerSide": true
why it works:
[code]
oTable = $('#price').dataTable({
"bProcessing": true,
//"bServerSide": true,
"sAjaxSource": "http://zamanpharm.kz/dub/templates/bt_okto/reload_price2.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (code){
fnCallback(code);
$.getJSON("http://zamanpharm.kz/dub/templates/bt_okto/names_price.php", function(data){
var i=0;
$("#price tbody tr").each(function(){
$(this).attr("name", data.id[i]);
i++;
});
});
summPlus();
summMinus();
summInput();
strDel();
}
} );
},
"sScrollY": $(window).height()-102,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
[/code]
as well - there is no:
[code]
oTable = $('#price').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://zamanpharm.kz/dub/templates/bt_okto/reload_price2.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (code){
fnCallback(code);
$.getJSON("http://zamanpharm.kz/dub/templates/bt_okto/names_price.php", function(data){
var i=0;
$("#price tbody tr").each(function(){
$(this).attr("name", data.id[i]);
i++;
});
});
summPlus();
summMinus();
summInput();
strDel();
}
} );
},
"sScrollY": $(window).height()-102,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
[/code]
[code]
oTable = $('#price').dataTable({
"bProcessing": true,
//"bServerSide": true,
"sAjaxSource": "http://zamanpharm.kz/dub/templates/bt_okto/reload_price2.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (code){
fnCallback(code);
$.getJSON("http://zamanpharm.kz/dub/templates/bt_okto/names_price.php", function(data){
var i=0;
$("#price tbody tr").each(function(){
$(this).attr("name", data.id[i]);
i++;
});
});
summPlus();
summMinus();
summInput();
strDel();
}
} );
},
"sScrollY": $(window).height()-102,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
[/code]
as well - there is no:
[code]
oTable = $('#price').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://zamanpharm.kz/dub/templates/bt_okto/reload_price2.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (code){
fnCallback(code);
$.getJSON("http://zamanpharm.kz/dub/templates/bt_okto/names_price.php", function(data){
var i=0;
$("#price tbody tr").each(function(){
$(this).attr("name", data.id[i]);
i++;
});
});
summPlus();
summMinus();
summInput();
strDel();
}
} );
},
"sScrollY": $(window).height()-102,
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
[/code]
This discussion has been closed.
Replies
One of my suggestions still holds: you don't need to (although you can) fully qualify the whole URL. Assuming you're in the same directory,
[code]
"sAjaxSource": "reload_price2.php",
[/code]
is a better way of stating your source.
I'm not sure I understand how to solve the problem, assuming what you're saying is that sAjaxSource does not work when bServerSide is true. Personally I would just forget about sAjaxSource and put my URL into the "url" parameter of my .ajax function (inside fnServerData).
how to do this?
p.s.
syntax highlighter do this: http://zamanpharm.kz/dub/templates/bt_okto/reload_price2.php"
just http://zamanpharm.kz/dub/templates/bt_okto/reload_price2.php
[code]
...
"bProcessing": true,
"bServerSide": true,
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": "reload_price2.php",
"data": aoData,
"success": function (code){
fnCallback(code);
$.getJSON ...
[/code]
the fnServerData function is passed sSource (whatever that might be at this point; it SHOULD have been your sAjaxSource, but you say it doesn't work), but then we just never use it. Instead we directly place the URL into the URL parameter of the $.ajax() call.
without "sAjaxSource" doesn't work!!!(((((
becouse i click on "next page button" - Ajax upload - my old events has disappeared(((((((((
why fnDrawCallback runs 2 times???
[code]function priceReload(){
oTable2.fnDestroy();
oTable2 = $('#zakaz').dataTable({
"sAjaxSource": 'http://zamanpharm.kz/dub/templates/bt_okto/reload_base.php',
"sScrollY": $("#rec_inner").height() - 65,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bPaginate": false,
"bFilter": false,
"bInfo": false,
"aoColumns": [
{ "sWidth": "40px" },
{ "sWidth": "500px" },
{ "sWidth": "60px" },
{ "sWidth": "145px" },
{ "sWidth": "65px" }
],
"fnDrawCallback": function() {
$.getJSON("http://zamanpharm.kz/dub/templates/bt_okto/names.php", function(data){
var i=0;
$("#zakaz tbody tr").each(function(){
$(this).children().next().next().next().addClass("edit");
$(this).attr("name", data.id[i]);
i++;
});
});
summPlus();
summMinus();
summInput();
strDel();
}
});
$('#search').focus().select();
}[/code]
Allan
replay from server, waiting a have long time, downloading not all (total 5000) and is empty
however param "username" has uploading on server
please help!
[code]oTable = $('#price').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "reload_price2.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push({ "name": "username", "value": xxx});
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
...[/code]
sorry for spelling, i'm from Russia
When you say "not all (total 5000)", are you actually expecting 5000 to be returned? That would not be the typical way of using server-side processing. Normally we use server-side because we want to send back a reduced data set (based on filtering and pagination).
no!!! i use server-side processing!
without "fnServerData" all works great.
but if data returned from server mach smaller (50 ), all downloading with "fnServerData" ))
what the reason of this?
thru 8 hours show reload_price2.php