I\'m using an ajax request to send comments to DB. Succesful response is marked by
1. OK
The problem actually is that the response from the
<?php
in your classQuote.php?>
?>
tag exists somewhere in the lines of code (follow flow from your __construct and where you invoke stuff)Infact, it could prove helpful to leave out the closing tag. Another possibility is this:
// capture output
ob_start();
require_once($ABS_APPS."/quotes/classQuote.php");
$quote = new Quote();
$quoteData = $quote->get($_POST["entryId"]);
// If user comments his own entry we don't have to send the notification
if($quoteData["UserAuthor"] != $_SESSION["User"]){
$notification->newComment($_POST["username"], $quoteData["UserAuthor"], $_POST["entryId"], $_POST["app"]);
// trim whitespace
echo trim(ob_get_clean());
}
I fixed by these
If you're using jQuery
you can use jQuery.trim(responseData) in your AJAX success callback, to get rid of the white spaces
see also here http://api.jquery.com/jQuery.trim/
hope it helps
I also faced the same problem. The final solution I figured out is following
Check all the files which are loaded into the file to which you are sending AJAX request
Remove the extra white spaces from the very first <?
line and PHP starting tag If your file starts from line number 1, the first ever character should be this <?
.
If they are PHP files, then don't add ?>
at the end.
Try to keep the last line marker only up to the last line of code written. means that do not add extra spaces at the end of the file. If code finishes at line 32, do not go to line number 33 via editor. In fact, press the back button and clear everything below up to line number 32.
If you are using any PHP framework, then make sure that the hierarchy of all files loaded should not have the same problem. e.g. if you are using codeigniter framework them make sure that the calling function's controller and all the models loaded into that controller should not have the same problem.