AJAX请求后,多余的新行返回 [英] Unwanted new line returned after AJAX request

查看:124
本文介绍了AJAX请求后,多余的新行返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个Ajax请求发送意见到数据库。成功的响应的特点是

  1。好
 

实际上,问题是,从PHP脚本的响应

  1。
2.确定
 

所以我调试的脚本,并指出,当脚本执行以下行添加换行符SI:

  require_once($ ABS_APPS/报价/ classQuote.php);
 

经过一番搜索,我读了它可能是一个BOM(字节顺序标记)的问题。所以,我只是下载并打开 classQuote.php 文件与十六进制编辑器,发现没有BOM ...有人可以帮我吗?

P.S。在我的项目的所有文件都encoted在UTF-8,而我目前USINT的NetBeans不增加BOM的文件。

这是牵连脚本:

  //发送新评论到数据库
情况下发送:
    $通知=新的通知();
    如果($ comment->插入($ _ POST [用户名],$ _ POST [意见],$ _ POST [应用],$ _ POST [ENTRYID])){
        开关($ _ POST [应用]){
            案行情:
                require_once($ ABS_APPS/报价/ classQuote.php。);
                $报价=新报价();
                $ quoteData = $经济通>获得($ _ POST [ENTRYID]);
                //如果用户评论自己的文章中,我们不必发送通知
                如果($ quoteData [UserAuthor]!= $ _SESSION [用户]){
                    $通知 - > newComment($ _ POST [用户名],$ quoteData [UserAuthor],$ _ POST [ENTRYID],$ _ POST [应用]);
                }
                打破;
            默认:
                打破;
        }
        回声确定;
    } 其他 {
        回声错误;
    }
    打破;
 

解决方案

这个问题是由 classQuote.php 所需的文件之一。总之感谢大家的帮助。

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 script is

1. 
2. OK

So I debugged the script and noted that the newline character si being added when the script executes the following line:

require_once($ABS_APPS."/quotes/classQuote.php");

After some searches i read that it could be a BOM (Byte Order Mark) problem. So I just downloaded and opened the classQuote.php file with an hex editor and noticed that there's no BOM... can someone help me?

P.S. All files in my project are encoted in UTF-8, and I'm currently usint NetBeans which doesn't add BOM to files.

This is the incriminated script:

// 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;

解决方案

The problem was in one of the files required by classQuote.php. Anyway thanks everyone for helping.

这篇关于AJAX请求后,多余的新行返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆