Reputation: 113
Hello I want to use Tiny mce editor and i want to take the text typed by the user and insert it in a database ca n anyone tell me how i would achieve this?
Upvotes: 2
Views: 498
Reputation: 50832
In order to do this you should call editor.triggerSave();
on one of the editor instances on your page.
This will update each elements for which a tinymce editor instance have been created.
Now, you can use an ajax call to send the html elements innerHTML to a remote php script where you can save the content to a db:
var content_to_be_send_using_ajax = $('#my_tinymce_htlm_element_id').innerHTML; // might be a textarea, a div or anything else
// now send it here to your php script
Another option is to use the saveplugin. When the save action is performed the form that the editor is within gets submitted.
Upvotes: 0
Reputation: 8382
TinyMCE typically replaces a standard form textarea - so on form submission, the textarea contents would be available to you via the standard $_POST array (e.g. $_POST['my_texarea']). You can then validate the contents and do your database insert.
Upvotes: 2