DBにコメントを送信するためにajaxリクエストを使用しています。成功した応答は、
1. OK
実際の問題は、php スクリプトからの応答が
1.
2. OK
そのため、スクリプトをデバッグしたところ、スクリプトが次の行を実行するときに改行文字 si が追加されていることがわかりました。
require_once($ABS_APPS."/quotes/classQuote.php");
いくつかの検索の後、BOM (Byte Order Mark) の問題である可能性があることを読みました。それで、ファイルをダウンロードして16進エディタで開いたところ、classQuote.php
BOMがないことに気づきました...誰か助けてもらえますか?
PS プロジェクト内のすべてのファイルは UTF-8 でエンコードされており、現在、ファイルに BOM を追加しない NetBeans を使用しています。
これは問題のあるスクリプトです。
// Send new comment to DB
case "send":
$notification = new Notification();
if($comment->insert($_POST["username"], $_POST["comment"], $_POST["app"], $_POST["entryId"])){
switch ($_POST["app"]) {
case "quotes":
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"]);
}
break;
default:
break;
}
echo "OK";
} else {
echo "ERROR";
}
break;