fnReloadAjax - Input parameters

fnReloadAjax - Input parameters

talkitivewizardtalkitivewizard Posts: 30Questions: 0Answers: 0
edited March 2010 in Plug-ins
Seriously it can't be this hard... I'm trying to figure how to get a callback to work on your plugin. I guess the biggest thing is I really don't know what the 1st parameter really is... however... this is what I have in code
[code]
init_ajax({
p: 'email2.view_live_emails',
page_action: action,
id: id
},{
callback: function(){
url = 'index.php?p=email2.view_live_emails&page_action=getData&includepreviews='+(jQuery('#includepreviews').attr('checked')?1:0)+'&includeinactive='+(jQuery('#includeinactive').attr('checked')?1:0);
live_emails_table.fnReloadAjax(live_emails_table.fnSettings(),url,function(){
console.log(jQuery('input[type=checkbox][value='+id+']').parent().parent());
});
}
});
[/code]

The problem I'm having is that the script hangs when I have the first parameter not be a URL or nothing... And by hangs I mean the script times out and firefox asks me if I want to stop it or continue with the message from Script: code/allanc/js/jquery-1.3.2.js:609 which happens to be in the function jQuery.fn.extend.

If I just do the following code... the ajax goes off without a hitch.
[code]
live_emails_table.fnReloadAjax(url);
[/code]


This is how I modified the plugin. jQuery is our jQuery variable because we also have prototype which uses the $. As you can see I've put a couple of console.logs through here. The funnything is.. it doesn't hit them till after I hit stop script. Any Ideas?
[code]
jQuery.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback )
{
if ( typeof sNewSource != 'undefined' )
{
oSettings.sAjaxSource = sNewSource;
}
console.log(oSettings.sAjaxSource);
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;

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

/* Got the data - add it to the table */
for ( var i=0 ; i

Replies

  • allanallan Posts: 55,114Questions: 1Answers: 8,654 Site admin
    DataTables will automatically add the settings parameter as the first parameter passed to the API function. I've just added a comment to the page to indicate that this is the case. The reason fort his is to provide a common interface for the API functions, but it can look slightly odd if you look at the parameters.

    Regards,
    Allan
  • antiplastikantiplastik Posts: 4Questions: 0Answers: 0
    Hello,

    I don't understand line 11 : why passing "null" as second parameter?
    [code]oSettings.fnServerData( oSettings.sAjaxSource, null, function(json) {[/code]

    Shouldn't we pass "oSettings.aoData" ?
    [code]oSettings.fnServerData( oSettings.sAjaxSource, oSettings.aoData, function(json) {[/code]

    It would make sense as you might want to use aoData when overriding the original fnServerData function (see Server-side data example) :

    [code]"fnServerData": function( sSource, aoData, fnCallback ) {
    aoData.push( { ... } );
    $.ajax( { ... } );
    }[/code]
This discussion has been closed.