我在获取 HTML 中 CKEDITOR 的值时遇到了问题。 在CKEDITOR中输入一些HTML标签并提交后。 POST 响应没有输出。这是我的代码。我不知道它是否有些复杂,因为我还使用了 jquery-validation 插件。
HTML
<?php echo form_open('users/user/sendEmail', array('id' => 'send-mail-form', 'role' => 'form')); ?>
<div class="row row_field">
<div class="col-md-12">
<label for="editor">Email Body:</label>
<textarea name="email_body" id="editor"></textarea>
</div>
</div>
JS
$('#editor').ckeditor();
jquery 验证
$('#send-mail-form').validate({
rules: {
email_subject: {
required: true,
minlength: 15
},
email_body: {
required: true,
minlength: 50
}
},
messages: {
email_subject: {
required: "The Email Subject is required",
minlength: "The email subject shoud be 15 characters and above."
},
email_body: {
required: "Email body is required",
minlength: "The email body should be 5o characters and above."
}
},
submitHandler: function(form) {
form.submit(); //send data
}
});
PHP 服务器端
public function sendEmail() {
fp($this->input->post()); //no output
fp(htmlentities($this->input->post('email_body'))); //no output also
你能帮我解决这个问题吗?
最佳答案
试试这个:
<script>
var data = CKEDITOR.instances.editor1.getData();
// Your code to save "data", usually through Ajax.
</script>
或者
<?php
$editor_data = $_POST[ 'editor1' ]; // where editor1 is the name of html element
?>
关于php - 如何在 PHP 中使用 POST 从 CKEDITOR 获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39072352/