ajax refresh
ajax refresh
Hi,
I'm getting confused on how to best go about refreshing my data table. I want to refresh my table based on a radio button change. On that change event, I want to do something like this:
$.ajax({
type: "POST",
url: "get_maps.php",
data: dataString,
dataType: "json",
success: function(data){
/* Example call to load a new file */
oDataTable.fnReloadAjax( 'get_maps.php' );
}
});
It seems the $.ajax is already getting the new data, so what do I send fnReloadAjax? Or should I be looping through the JSON response on success and doing a fnAddData? I do need to do a post as the data loaded in my PHP needs a parameter. Thanks in advance for any help.
I'm getting confused on how to best go about refreshing my data table. I want to refresh my table based on a radio button change. On that change event, I want to do something like this:
$.ajax({
type: "POST",
url: "get_maps.php",
data: dataString,
dataType: "json",
success: function(data){
/* Example call to load a new file */
oDataTable.fnReloadAjax( 'get_maps.php' );
}
});
It seems the $.ajax is already getting the new data, so what do I send fnReloadAjax? Or should I be looping through the JSON response on success and doing a fnAddData? I do need to do a post as the data loaded in my PHP needs a parameter. Thanks in advance for any help.
This discussion has been closed.
Replies
i have tried ,
[code]
success: function(data){
oTable.fnClearTable(0);
oTable.fnAddData(data);
oTable.fnDraw();
}
[/code]
data is a json string and in the api it says its possible to add multiple rows with fnAddData. yet when i do thati it says columns do not match , and its the same query working... Is there way to make a Ajax Load with post parameters? if so can someone give an example or some pointers?
EDIT:
i have tried ,
[code] "fnServerData" : function(sSource, aoData, fnCallback){
$.ajax({
"dataType" : 'json',
"type" : "POST",
"url" : sSource,
"data" : aoData,
"success" : fnCallback
});
[/code]
I guess this will do what i want to do , yet i cant call fnServerData from an event...
Kind regards
In general, there are two questions here.
1. Is there a way to pass arguments to the ajax when I do fnDraw?
2. If there isn't a way to impact the server, does it mean that I need to erase the current dataTable and start from scratch?
3. What's the API to erase a dataTable?
4. Why when my ajax comes back from any API command it is not taken by the dataTable. (the "processing" icon keeps going)
Thanks,
Uri
650 330-0651
[code]
$.ajax({
type: "POST",
url: "get_maps.php",
data: dataString,
dataType: "json",
success: function(data){
/* Example call to load a new file */
oDataTable.fnReloadAjax( 'get_maps.php' );
}
});
[/code]
there's a simple solution for that yet it took me a day to figure that out.
the data is coming in json format , just do
[code]
success: function(data){
/* Example call to load a new file */
oDataTable.clearTable();
oDataTable.fnAddData(data.aaData); //the data part of your json message
oDataTable.fnDraw();
}
[/code]
i hope this will do the trick ... yet i couldn't manage to do it with server side processing
Regards,
Allan