jQuery AJAX JSON-文本区域字符问题

jQuery AJAX JSON-文本区域字符问题,jquery,html,ajax,json,textarea,Jquery,Html,Ajax,Json,Textarea,我有一个注释系统的代码 jQuery: function sendComment() { $('#comment_write_area').fadeOut(1); $('#ajax-json-response').fadeOut('fast').html(''); $('#ajax-loading').html('<img src="images/ajax-loader.gif" />').fadeIn('slow'); var comment = $('#comment').val

我有一个注释系统的代码

jQuery:

function sendComment() {
$('#comment_write_area').fadeOut(1);
$('#ajax-json-response').fadeOut('fast').html('');
$('#ajax-loading').html('<img src="images/ajax-loader.gif" />').fadeIn('slow');
var comment = $('#comment').val();
var news_id = $('#news_id').val();
var user_id = $('#user_id').val();
var logged_in = $('#logged_in').val();
var number = $('#number').val();
$.ajax({
    type: 'POST',
    url: 'json.php',
    dataType: 'json',
    cache: false,
    timeout: 20000,
    data: { a: 'comment_add', comment: comment, news_id: news_id, user_id: user_id, logged_in: logged_in, number: number },
    success: function(data) {
        $('#ajax-loading').fadeOut(1).html('');
        $('#comment_write_area').slideToggle('slow');
        $('#comment').val('');
        $('#ajax-json-response').html(data.message).fadeIn('slow');
        if (!data.error) {
            $('input#number').val(data.nextnumber);
            $('#ajax-response').after(data.comment);
            $('#comment_'+data.nextnumber).slideToggle('slow');
            $('#no-comment').fadeOut('slow');
        }
    },
    error: function(jqXHR, textStatus, errorThrown) {
        $('#ajax-loading').fadeOut(1).html('');
        $('#comment_write_area').fadeIn('slow');
        $('#comment').val('');
        //$('#ajax-json-response').html('Probléma történt! Kérlek próbáld újra később! (HTTP Error: '+errorThrown+' | Error Message: '+textStatus+')').fadeIn('slow');
        $('#ajax-json-response').html('Probléma történt! Kérlek próbáld újra később, és ellenőrizd az internetkapcsolatod!').fadeIn('slow');
    }
}); }
jSON PHP是这样的:

elseif ($_POST['a'] == 'comment_add') {
if ($_POST['logged_in']) {
    if (!empty($_POST['comment']) && !empty($_POST['news_id']) && !empty($_POST['user_id'])) {
        $number = $_POST['number'] + 1;
        $_POST['comment'] = $do->htmlEncode($_POST['comment']);
        $return['nextnumber'] = $number;
        $return['error'] = false;
        $return['message'] = '<font style="color: green;">'.$nsite->json('DO_COMMENTS_SUC').'</font>';
        $do->mysqlSelect('user', 'icl_users', 'WHERE id = "'.$_POST['user_id'].'"');
        mysql_query("INSERT INTO icl_comments (name, content, news_id, date) VALUES ('".$do->msS('user', 'username')."', '".nl2br($_POST['comment'])."', '".$_POST['news_id']."', '".date("Y-m-d H:i:s")."')");
        $do->mysqlSelect('comment', 'icl_comments', 'WHERE `name` = "'.$do->msS('user', 'username').'" ORDER BY id DESC LIMIT 1');
        $return['comment'] = $do->genComment($do->msS('comment', 'id'), $do->msS('user', 'username'), $do->msS('user', 'id'), $do->msS('user', 'userpic'), $number, date("Y-m-d H:i:s"), $_POST['comment'], $site_color);
    } else {
        $return['error'] = true;
        $return['message'] = '<font style="color: red;">'.$nsite->json('DO_COMMENTS_DEL_ERROR_3').'</font>';
    }
} else {
    $return['error'] = true;
    $return['message'] = '<font style="color: red;">'.$nsite->json('POLLS_NO_LOGIN').'</font>';
}
echo json_encode($return); }
我的问题是,当我在文本区域中写入',字符时,它会显示'like this:\'。在我刷新站点并从MySQL中读取之后,它显示的非常完美

你能告诉我原因吗


谢谢

php函数stripslashes可能有助于