Unwanted new line returned after AJAX request

后端 未结 4 537
执念已碎
执念已碎 2021-01-13 05:23

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

4条回答
  •  清酒与你
    2021-01-13 06:03

    1. Make sure there is nothing, preceeding the opening in your classQuote.php
    2. Make sure there are no trailing characters / lines after the closing ?>
    3. Check to see if a ?> 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()); 
                }
    

提交回复
热议问题