After extensive research, I have not been able to find the answer I'm looking for despite similar questions being asked.
My query concerns the usage of for(;;); while(1); before an Ajax response outputs a JSON string.
I am curious about how this technique works and would like to implement it similarly to popular sites such as Facebook.
In the ajax.php file, I believe the following needs to be done:
ajax.php
$arr = array("value" => "something", "moreValues" => "moreSomething");
die("for(;;);".json_encode($arr));
The response will look like this:
for(;;);{"value":"something","moreValues":"moreSomething"}
What should one do with this string? Should we remove for(;;); with a substr or something and then use JSON.parse(string)? (If so, why include for(;;); in the response at all?)
Furthermore, how does this approach enhance security and guard against potential infinite loops with the for(;;); statement if something goes wrong?
I feel like there is a missing piece to this puzzle, and I am yet to find a clear example illustrating how to execute this. Any guidance or examples demonstrating the implementation in code would be greatly appreciated! Thanks!