我用了一個編輯器叫quill
var quill = new Quill('#editor', {
modules: {
toolbar: toolbarOptions
},
placeholder: 'Compose an epic...',
theme: 'snow'
});
var form = document.querySelector('form');
form.onsubmit = function() {
// Populate hidden form on submit
var content = document.querySelector('input[name=content]');
content.value = JSON.stringify(quill.getContents());
console.log("Submitted", $(form).serialize(), $(form).serializeArray());
alert('Open the console to see the submit data!')
return false;
};
我想把它content的內容丟到sql但是這是json格式。。。
0: {name: "title", value: ""}
1: name: "content"value: "{"ops":[{"insert":"srgsegsrehreshrseh"},{"attributes":{"blockquote":true},"insert":"\n"}]}"__proto__: Object
2: {name: "tag", value: ""}
3: {name: "password", value: ""}length: 4__proto__: Array(0)
我title, tag, password 都是用php的POST去接值然後匯入到SQL但唯獨content他是直接丟json.....那我要怎麼轉換才對?因為我真正需要的是html而不是json,但是找了一下官方改掉getHtml的API。。。。
添加回答
举报
0/150
提交
取消