fnReloadAjax Issue

fnReloadAjax Issue

saifursaifur Posts: 20Questions: 0Answers: 0
edited May 2012 in General
Hi, I am new in datatables and quiet happy with this but now stuck in fnReloadAjax plugin. I am pasting my whole code here.
[code]


$(document).ready(function() {
//find all form with class jqtransform and apply the plugin

$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
//alert(sNewSource);

if ( typeof sNewSource != 'undefined' && sNewSource != null )
{
oSettings.sAjaxSource = sNewSource;
}
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
var iStart = oSettings._iDisplayStart;
var aData = [];

this.oApi._fnServerParams( oSettings, aData );

oSettings.fnServerData( oSettings.sAjaxSource, aData, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );

/* Got the data - add it to the table */
var aData = (oSettings.sAjaxDataProp !== "") ?
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;

for ( var i=0 ; i

Replies

  • saifursaifur Posts: 20Questions: 0Answers: 0
    Is there anyone who can help me in this regard?
  • allanallan Posts: 63,548Questions: 1Answers: 10,476 Site admin
    Can you link to your page please. It looks to me that this should be working.

    Allan
  • saifursaifur Posts: 20Questions: 0Answers: 0
    URL:
    http://www.saifur.com/victor/admin
    It will ask for user name and password, use the following credentials.
    user: saifur
    pass: mankind

    then there you will find a menu, go to photo->add new
    That is the page I am asking help for.

    Thanks in advance.
  • allanallan Posts: 63,548Questions: 1Answers: 10,476 Site admin
    You've got a JS syntax error after "$('.editdescription').editable('" - there is a new line character and a whole other bunch of white space in there.

    Allan
  • saifursaifur Posts: 20Questions: 0Answers: 0
    I don't think that is the reason. Fixed that. Now have a look. Still not getting any response.
  • saifursaifur Posts: 20Questions: 0Answers: 0
    I can see a blink of "Processing" but the table is not updated with new data.
  • allanallan Posts: 63,548Questions: 1Answers: 10,476 Site admin
    This is what is coming back from the server:

    [code]
    {"sEcho":1,"iTotalRecords":0,"iTotalDisplayRecords":0,"aaData":[]}
    [/code]

    so DataTables is showing exactly that - 0 records. So I would guess that there is a fault in the server-side processing script if you are expecting it to return data.

    Allan
  • saifursaifur Posts: 20Questions: 0Answers: 0
    It is returning data if you select "another" from the options. But table is now reloading with data. If you select the first option there is no data.
  • saifursaifur Posts: 20Questions: 0Answers: 0
    Try uploading a file, then you can see, when the page is reloaded the data is coming.
  • saifursaifur Posts: 20Questions: 0Answers: 0
    Hi Allan,
    Can you have a look now. I can see the "Processing". But noting comes. How can I inspect the status?
  • saifursaifur Posts: 20Questions: 0Answers: 0
    The following code is responsible for sending data from the server.
    [code]
    $aColumns = array( 'id', 'url', 'photoname', 'description', 'action' );
    if($this->input->post('albumid')){
    $albumid = $this->input->post('albumid');
    }elseif($this->uri->segment(3) != FALSE){
    $albumid = $this->uri->segment(3);
    }
    else{
    $albumid = 0;
    }

    $this->load->model('Photo');
    $result = $this->Photo->get_json_images_by_album($albumid);
    /*
    * Output
    */
    $output = array(
    "sEcho" => 1,
    "iTotalRecords" => count($result),
    "iTotalDisplayRecords" => count($result),
    "aoData" => array()
    );



    $aaData = array();
    foreach($result as $imagedata){
    $row = array();

    $row[] = $imagedata->id;
    $row[] = "";
    $row[] = "".$imagedata->photoname."";
    $row[] = "".$imagedata->description."";
    $row[] = "DELETE";


    $aaData[] = $row;

    }

    //print_r($result);


    $output['aoData'] = $aaData;

    echo json_encode( $output );
    [/code]
  • saifursaifur Posts: 20Questions: 0Answers: 0
    Hi Allan, can you check. I pass a different value at the beginning the data is show during page load. But when I call reload with the same URL it doesn't work.
  • allanallan Posts: 63,548Questions: 1Answers: 10,476 Site admin
    If I upload a photo it reloads the whole page (so no need for fnReloadAjax) but it doesn't show the photo. Would you have expected it to show up in the list?

    Allan
  • saifursaifur Posts: 20Questions: 0Answers: 0
    Try the page now. As I am passing the parameter sValue along with URL. the initial value I set to a value which has data. It works fine. But when I call fnReloadAjax, it even receives the data from the server but somehow the table is not redrawn. You can see the code now. I have even testing by this portion of code [code]

    for ( var i=0 ; i
  • allanallan Posts: 63,548Questions: 1Answers: 10,476 Site admin
    Exactly the same as before - I upload a photo, the page reloads and my photo doesn't appear. I guess I'm missing something.
  • saifursaifur Posts: 20Questions: 0Answers: 0
    This alert shows data like data1, data2, data3, data4, data5

    Where data is what I am expecting?
    Is that a correct format of what aData[i] should be?
This discussion has been closed.