我正在尝试将 Ajax 与 JQuery 一起使用,我想做的只是使用 Ajax 将多行文本框值发送到 php。
我正在使用该代码,它将 txtAnswer 值发送到 php,不幸的是,它从数据中删除了新行 (\n)。我该如何解决这个问题...提前致谢。
$.post(
'post-answer.php',
{
answer: $("#txtAnswer").val(),
qid: <?= $question_ID ?>
},
function (ajaxResponse) {
$('#answers').html(ajaxResponse)
}
);
最佳答案
尝试:escape( $("#txtAnswer").val() )
=-)
关于php - 使用 JQuery 通过 Ajax Post 向服务器发送请求时删除新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1183466/