Javascript 使用jQuery Ajax保存Tinymce
我在应用程序中使用Tinymce作为编辑器。我需要用户能够将Tinymce中的内容保存到MySQL数据库中。我知道后端工作正常,因为我可以将常规输入的内容保存到数据库,但Tinymce工作不正常。内容将作为以下内容发布到我的web应用程序:Javascript 使用jQuery Ajax保存Tinymce,javascript,jquery,ajax,spring-boot,tinymce,Javascript,Jquery,Ajax,Spring Boot,Tinymce,我在应用程序中使用Tinymce作为编辑器。我需要用户能够将Tinymce中的内容保存到MySQL数据库中。我知道后端工作正常,因为我可以将常规输入的内容保存到数据库,但Tinymce工作不正常。内容将作为以下内容发布到我的web应用程序: [object Object] Tinymce init <script> tinymce.init({ selector: "input.form-control", plugins: [ "advlist
[object Object]
Tinymce init
<script>
tinymce.init({
selector: "input.form-control",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste", "save"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | save",
save_enablewhendirty : false,
save_onsavecallback: function () {var todo = tinyMCE.get('content'); createTodo(todo); countTodos(); console.log(todo)}
});
</script>
这也存在于console.log中
XML Parsing Error: no root element found
Location: http://localhost:8080/stuffs/[object%20Object]
Line Number 1, Column 1:
另外,我的应用程序在Spring Boot中
更新:我可以使用我的save\u onsavecallback中的以下代码在警报框中传递HTML内容
var mce = tinyMCE.get('content'); var todo = mce.getContent(); alert(todo);
但是,我得到一个405“不允许使用方法”
Spring工具套件在控制台中显示:
o.s.web.servlet.PageNotFound Request method 'POST' not supported
使用todo=$(“.input.form control”).html()代替todo=tinyMCE.get(),对吗?是的。您现在使用的方法没有得到htmlMy bad,应该在开始时没有点:$(“input.form control”),这现在似乎是一个与服务器相关的错误。最好使用$.post(“/stuffs”,{html:text})将数据作为post而不是url发送
var mce = tinyMCE.get('content'); var todo = mce.getContent(); alert(todo);
o.s.web.servlet.PageNotFound Request method 'POST' not supported