I tried to fetch >30,000 Records as a JSON Data, I Can't able to get the proper response. But I tried the PHP Service directly to print the JSON, it prints the actual record without any bug. But in AngularJS , I can't able to fetch the actual number of records.
My Sample JSON Data
{
"records":[
{
"ldat":"2014-08-13",
"eid":"HSL018",
"dr":"55420",
"cr":"0",
"bal":"55420"
},
{
"ldat":"2014-10-11",
"eid":"HBL056",
"dr":"0",
"cr":"35000",
"bal":"20420"
},
{
"ldat":"2014-10-26",
"eid":"HBL001",
"dr":"0",
"cr":"420",
"bal":"20000"
},
----- 30,000 Records -----
,
{
"ldat":"2015-11-01",
"eid":"HDL001",
"dr":"0",
"cr":"20000",
"bal":"0"
}
]
}
while on debugging, I got only partial output from the Response.
{
"records":[
{
"ldat":"2014-08-13",
"eid":"HSL018",
"dr":"55420",
"cr":"0",
"bal":"55420"
},
{
"ldat":"2014-10-11",
"eid":"HBL056",
"dr":"0",
"cr":"35000",
"bal":"20420"
},
{
"ldat":"2014-10-26",
"eid":"HBL001",
"dr":"0",
"cr":"420",
"bal":"20000"
},
----- 4,000 Records -----
,
{
"ldat":"2015-11-01",
"eid":"HDL0
Let I know is there is any limits are there in the Response
? How to get the entire record as a response? Kindly assist me...
The Response Header Details which I was got
HTTP/1.1 200 OK
Date: Thu, 11 Feb 2016 01:31:45 GMT
Server: Apache
Access-Control-Allow-Origin: *
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=10, max=500
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json; charset=UTF-8
My PHP Service Script
<?php
ob_start(); // start normal buffer
ob_start("ob_gzhandler"); // start gzip buffer
echo $content;
ob_end_flush(); // output gzipped content
$gzippedContent = ob_get_contents(); // store gzipped content to get size
header('Content-Length: '.strlen($gzippedContent));
ob_end_flush(); // flush gzipped content
?>
Use the following PHP Script to test the task, it will produce the 35,000 records.
PHP Script : Statement.php
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$content = "";
for($i=1; $i<=35000; $i++) {
if ($content != "") {
$content .= ",";
}
$content .= '{"slr":' . $i . ',';
$content .= '"uid":' . rand(100,10000) . ',';
$content .= '"name":"Balamanigandan",';
$content .= '"cell":"9999999999",';
$content .= '"balance":10000,';
$content .= '"ltrans":"2015-01-01",';
$content .= '"msg":" Opening Balance"}';
}
$content = '{"records":[' . $content . ']}';
ob_start(); // start normal buffer
ob_start("ob_gzhandler"); // start gzip buffer
echo $content;
ob_end_flush(); // output gzipped content
$gzippedContent = ob_get_contents(); // store gzipped content to get size
header('Content-Length: '.strlen($gzippedContent));
ob_end_flush(); // flush gzipped content
?>
The AngularJS Sample Script to fetch the records
var stmt= angular.module('Statement', []);
stmt.controller('StmtCtrl', function($scope, $http, $cacheFactory) {
var request = $http({
method: "post",
url: "Statement.php",
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
request.success(function (response)
{
$scope.data = response;
});
});
Note: I don't get any error, but I'm getting the partial output as a Response.