If you want to do for example a var_dump without corrupting your data on ajax you can do this:
ob_start();
var_dump($yourvar);
$data = ob_get_clean();
$fp = fopen(« outputdata.txt », « w »);
fwrite($fp, $data);
fclose($fp);
ob_end_clean();
Then go to the folder where you have put the file.
The result is the var_dump will not be displayed to the user and catch directly into the file so your ajax will not be corrupted.