Click here to Skip to main content
15,851,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

I want to Compress JSON Data at Client Side. After I want to send this data to PHP. I have too loger data in json format so it's take too much time to process on that data. So I want to compress my json and after forward it to PHP.

JavaScript
<html>
<head>
	<script src="main.js"></script>
	<script src="package.js"></script>
	<script src="package.json"></script>
	<script src="test.js"></script>
	
	<script>
		var xmlhttp;
	if (window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
	}else{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
			var replay = xmlhttp.responseText;
		}
	}
	xmlhttp.open("POST","generatereport.php",true);
	var variable = 'Here my JSON Data';
	variable = jsonpack.pack(variable);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", variable.length);
	xmlhttp.send(variable);
	</script>
</head>
</html>

Please Help me for this. Thank you in Advance.

What I have tried:

I have already use CJSON, RJSON, jsonpack etc. but I can't get success.
Posted
Updated 14-Jul-16 5:05am
v2
Comments
Patrice T 14-Jul-16 10:06am    
Can you give details on "can't get success" ?
F-ES Sitecore 14-Jul-16 10:14am    
Even if you compress it to send over the network you still need to process it all at the other end. Are you sure it is the network call that is your bottleneck and not the processing of the data in your php?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900