Usingg the Ajax request i get content which is displayed on the web page.
The content can be only strings / string + html content / string + images.
I need to calculate the total size of the content and if it exceeds 200Kb, I do not have to show it on the HTML page.
How do i calculate the size of the content in either jQuery/Angualarjs/Javascript/PHP?
Modify your PHP backend:
ob_start();
// all content generated here ...
$output = ob_get_clean();
if ( strlen($output) > (200*1024) ) {
//return error to frontend
} else {
echo $output;
}
ob_start();
$output = ob_get_length();
or if you have to set the content-length param then add the following to above code:
header("Content-Length: $output");