Reference to XHR Not Passed For xhr.dt When Using Pipline Plugin

Reference to XHR Not Passed For xhr.dt When Using Pipline Plugin

zepernickzepernick Posts: 32Questions: 7Answers: 0

This is cross posted in SO: https://stackoverflow.com/questions/59845554/jquery-datatables-reference-to-xhr-not-passed-for-xhr-dt-when-using-pipline-plug

DataTables version: 1.10.20

I am currently using the pipeline plugin and listening for the xhr event . The xhr event is firing as expected, however, the xhr parameter on the callback is undefined. There is also a jqXhr property in the setting object, but this is also undefined.

Below is a snippet from the pipeline plugin

settings.jqXHR = $.ajax( {
                "type":     conf.method,
                "url":      conf.url,
                "data":     request,
                "dataType": "json",
                "cache":    false,
                "success":  function ( json ) {
                    cacheLastJson = $.extend(true, {}, json);

                    if ( cacheLower != drawStart ) {
                        json.data.splice( 0, drawStart-cacheLower );
                    }
                    if ( requestLength >= -1 ) {
                        json.data.splice( requestLength, json.data.length );
                    }

                    drawCallback( json );
                }
            } );

The drawCallback() seems to be what is triggering the xhr event. It utilizes the settings.jqXHR (being set in the code above) to pass the xhr parameter back to the event. Since this success is a async callback, I would expect setting.jqXHR to be available from within the settings object, yet it is undefined from within drawCallback().

Another alternative I am contemplating is modifying the pipline code to trigger the xhr event, however, this would lead to the event firing 2x since it is already being triggered in drawCallback(). It does not seem like the proper way to resolve the issue.

Has anyone had any success hooking into the xhr event with the pipline plugin and accessing the xhr parameter, or have any suggestions on how to remedy the issue?

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.