get gzipped data by AJAX request

get gzipped data by AJAX request

WilziWilzi Posts: 1Questions: 0Answers: 0
edited October 2011 in General
Dear Support,

I'm interested in how to recieve gzipped data from the server by XHR request?
I'm using this code to enable gzip compression on the server:

ob_start( 'ob_gzhandler' );
header( 'Content-type: application/json; charset=UTF-8' );
header( 'Content-Encoding: gzip' );

But nothing appears in the table :(
Do I need any additional options enable to recieve data by this way?

Thanks for your help and this great plugin!

Best regards
Adam

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    "If the web service is implemented correctly and you're querying it via XHR (e.g., jQuery's ajax or related functions), the browser should unzip it for you before you see it; the fact it's gzipped should be completely transparent to you."

    http://stackoverflow.com/questions/2956283/decode-gzip-using-jquery-javascript

    (I can't vouch for the answer, but it sounds legit.. I believe the browser will have taken care of any decoding of gzip before javascript/DataTables sees it)

    this is all beyond the scope of DataTables, but you should detect if the browser sent a header allowing gzip before encoding your data.
This discussion has been closed.