单引号后的其余字符串将被丢弃

rest of the string after single quote is thrown away

本文关键字:字符串 单引号      更新时间:2023-09-26

CKEDITOR.instances.content.getData()有一个文本,类似于这是一个"球"

我使用ajax将以下数据发送到php页面,并将其存储到数据库中

var data="answerswer_body="+CKEDITOR.instances.content.getData()+"&userpost_post_id=<?php echo $contents[0]->post_id;?>&users_user_id=<?php echo $userdata->user_id; ?>";

但答案正文在引用后丢弃了正文的其余部分。

 $answer=addslashes($_POST['answer_body']);
   echo $answer; // it contains only -----------This is a

我怎样才能解决这个问题?

尝试以下Ajax代码将数据从客户端发送到服务器

$.ajax({
    type: 'POST',
    url: "Here_Your_Server_Url",
    data: {
        answer_body: encodeURIComponent(CKEDITOR.instances.content.getData()),
        userpost_post_id: "<?php echo $contents[0]->post_id; ?>",
        users_user_id: "<?php echo $userdata->user_id; ?>"
    }
})

在PHP 中尝试以下代码

$strAnswerBody = urldecode($_POST['answer_body']);