Kindeditor:ajax cannot get HTML content when submitting a form

Source: Internet
Author: User

When submitting a form with Ajax, the content of the kindeditor is not available, and the HTML data cannot be retrieved

Cause: When Ajax commits, Kindedito's HTML data is not synced to the form, so how do you get the HTML data?

---------------------------------------------------

Kindeditor 4.x Documentation: Get HTML data

Get HTML content
html = editor.html ();

The value of textarea can be obtained directly after synchronizing the data
Editor.sync ();
html = document.getElementById (' editor_id '). Value; Native API
html = K (' #editor_id '). Val (); Kindeditor Node API
html = $ (' #editor_id '). Val (); Jquery

Set HTML content
editor.html (' HTML content ');

----------------------------------------------------

From this we can see that when Ajax submits the form, the value of textarea is empty, and Sync () is used to synchronize the HTML data

So when to sync, how to sync? Kindeditor also provides a method:

Afterblur

The callback function that is executed when the editor loses focus (Blur).

Data type: Function
Default value: None

Final Answers and Solutions:

    <script type= "Text/javascript" >        kindeditor.ready (function  (K) {            = K.create (' #AContent ', {                functionthis. sync ();}            );        });     </script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.