Compress data in php and uncompress in javascript -
greerings all
is there way compress data sent php (server) , uncompress data using javascript (client)?
thanking you
i have agree @domenic's answer here. @nishchay sharma way off.
the thing i'll add if want on per-script basis rather configuring entire server compress everything, it's trivial accomplish goal using php's gzencode() function coupled header call:
http://www.php.net/manual/en/function.gzencode.php
for instance, let's retrieving huge set of data via ajax call php page. configure php page use gzencode follows:
<?php $somebigstring = gzencode('blahblah...blah'); header("content-type: text/javascript"); header('content-encoding: gzip'); echo $somebigstring; ?> (this overly simplified, of course, i'm keeping simple.)
your js ajax call pull data down, see gzip header, , decompress automagically. use technique large geo-coordinate data sets google maps can many megabytes in size when uncompressed. couldn't easier!
Comments
Post a Comment