fnAjaxReload problem with aaData

fnAjaxReload problem with aaData

valdezrvaldezr Posts: 49Questions: 0Answers: 0
edited January 2010 in General
I am using the plugin to reload ajax content

$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource ) {
if ( typeof sNewSource != 'undefined' )
oSettings.sAjaxSource = sNewSource;

this.fnClearTable( this );
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;

$.getJSON( oSettings.sAjaxSource, null, function(json) {
/* Got the data - add it to the table */
for ( var i=0 ; i

Replies

  • allanallan Posts: 63,113Questions: 1Answers: 10,396 Site admin
    Is your json data in this format: http://datatables.net/examples/examples_support/json_source.txt . I'm guessing not is aaData is undefined.

    Regards,
    Allan
  • valdezrvaldezr Posts: 49Questions: 0Answers: 0
    Thanks Allan,
    The problem was in the server.
    I solved it,
    thanks again.
  • bsakwebsakwe Posts: 2Questions: 0Answers: 0
    edited May 2010
    Hello Allan, please permit me to begin by expressing my profound gratitude to you for the marvelous job you did on creating this plugin, obviously I am talking about the DataTable plugin. I found it on google and after playing with it, I realized it is the most powerful I have seen in recent times.

    However, I am having a small problem with retrieving data from my RESTful webservice using ajax.

    [code]
    function initializeRoleDataTable(){
    $('#roleTable').dataTable({
    "aaSorting": [[0, "asc"]],
    "aoColumns": [null, null, null],
    "sPaginationType": "full_numbers",
    "bProcessing": true,
    "bStateSave": true,
    "sAjaxSource": "../rest/roles",
    "fnServerData": function(sSource, aaData, fnCallback){

    $.ajax({
    "dataType": "json",
    "type": "POST",
    "url": sSource,
    "data": aaData,
    "success": fnCallback
    });
    }
    });
    [/code]

    The above is my initialization method that is call in the snipet bellow
    [code]
    $(function(){
    initializeRoleDataTable();
    });
    [/code]

    When the js code is executed, this method
    [code]
    @SuppressWarnings("unchecked")
    @POST
    @Path("/roles")
    @Produces(MediaType.APPLICATION_JSON)
    public String getAllRoles(){
    List list = (List) knockageService.findAll(Role.class);
    Gson gson = new Gson();
    String val = gson.toJson(list);
    return val;
    }
    [/code]

    is called.

    My Jersey filter logger produce this result

    [code]
    May 12, 2010 11:13:37 AM com.sun.jersey.api.container.filter.LoggingFilter$Adapter finish
    INFO: 1 * Server out-bound response
    1 < 200
    1 < Content-Type: application/json
    1 <
    [{"roleName":"ROLE_ADMIN","users":[],"id":497,"creationDate":"May 8, 2010 3:56:43 PM","version":0},{"roleName":"ROLE_USER","users":[],"id":498,"creationDate":"May 8, 2010 3:56:43 PM","version":0},{"roleName":"ROLE_PLAYER","users":[],"id":499,"creationDate":"May 8, 2010 3:56:43 PM","version":0},{"roleName":"ROLE_ANONYMOUS","users":[],"id":500,"creationDate":"May 8, 2010 3:56:43 PM","version":0},{"roleName":"ROLE_POWER","users":[],"id":501,"creationDate":"May 8, 2010 3:56:43 PM","version":0},{"roleName":"ROLE_EXECUTIVE","users":[],"id":502,"creationDate":"May 8, 2010 3:56:43 PM","version":0},{"roleName":"ROLE_PRESIDENT","users":[],"id":503,"creationDate":"May 8, 2010 3:56:43 PM","version":0}]
    [/code]

    but unfortunately I kept getting the error
    [code]
    json.aaData is undefined
    oSettings.fnServerData(oSettings.sAjax...on){for(var i=0;i
This discussion has been closed.