我正在使用 ajax 请求将评论发送到数据库。成功的响应标记为
1. OK
问题实际上是来自 php 脚本的响应是
1.
2. OK
所以我调试了脚本并注意到在脚本执行以下行时添加了换行符 si:
require_once($ABS_APPS."/quotes/classQuote.php");
经过一些搜索,我读到它可能是 BOM(字节顺序标记)问题。所以我刚刚下载并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;