Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我不能用填充textarea,顺便说一句,我使用的是ajax_Php_Jquery_Ajax - Fatal编程技术网

Php 为什么我不能用填充textarea,顺便说一句,我使用的是ajax

Php 为什么我不能用填充textarea,顺便说一句,我使用的是ajax,php,jquery,ajax,Php,Jquery,Ajax,这是我使用的ajax $.ajax({ type: "POST", url: "../../Ajax/<?php echo $exercise_num ?>", data: "user_input=" + user_input, success: function(resp){ //output $("#message").text(resp); } }); } 我的html代码: 信息: 输出: 信息:10+7=17 hi 或者有没有办法在字体的文本区域中使用br?文本区域中不

这是我使用的ajax

$.ajax({
type: "POST",
url: "../../Ajax/<?php echo $exercise_num ?>",
data: "user_input=" + user_input,
success: function(resp){
//output
 $("#message").text(resp);
}
});
}
我的html代码: 信息:

输出: 信息:10+7=17 hi


或者有没有办法在字体的文本区域中使用br?

文本区域中不能有html。它不会被正确地解释,应该被转义以防止注入。您要使用换行符:

echo "\n\nhi";

文本区域内不能有html。它不会被正确地解释,应该被转义以防止注入。您要使用换行符:

echo "\n\nhi";
试试这个:

$message.textresp.replace\n

参考:

试试这个:

$message.textresp.replace\n

ref:

您可以替换为\n, 最重要的是你们不能把html标签放在textarea值上

$.ajax({
type: "POST",
url: "../../Ajax/<?php echo $exercise_num ?>",
data: "user_input=" + user_input,
success: function(resp){
//output
    $("#message").text(resp.split("<br>").join("\n"));
}
});
}
您可以替换为\n, 最重要的是你们不能把html标签放在textarea值上

$.ajax({
type: "POST",
url: "../../Ajax/<?php echo $exercise_num ?>",
data: "user_input=" + user_input,
success: function(resp){
//output
    $("#message").text(resp.split("<br>").join("\n"));
}
});
}

@3第一个回答消失但不换行这是输出消息:10+7=17 hi@3第一个回答消失但不换行这是输出消息:10+7=17 Hit消失但不换行这是输出消息:10+7=17hi@MarkJeffreyCalvarioLopez您可能需要使用两个NewLinesName输出:消息:10+7=17 hi忽略:123456789@MarkJeffreyCalvarioLopez我不知道该告诉你什么;我没有问题我发现了一些东西ff,chrome浏览器不显示它有换行符,但当我检查元素时,它显示。你认为问题出在哪里?换行符消失了,但没有换行符这是输出信息:10+7=17hi@MarkJeffreyCalvarioLopez您可能需要使用两个新行名称输出:Message:10+7=17 hi忽略:123456789@MarkJeffreyCalvarioLopez我不知道该告诉你什么;我没有问题我发现了一些东西ff,chrome浏览器不显示它有换行符,但当我检查元素时,它显示。你认为问题出在哪里?