I have a form, which add some data to DataBase.

 <input type="text" name="mydata" />
 <textarea name="mytext"></textarea>
 <?php echo JHtml::_( 'form.token' );?>
 <button type="submit">Submit</button>

Clicking Submit, I send data to outside script, which insert data to DB. I'm checking session token (to prevent csrf attack) and then make script actions. To do this, I use Joomla JSession method checkToken().

define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));

require_once ( JPATH_BASE. '/includes/defines.php' );
require_once ( JPATH_BASE. '/includes/framework.php' );

$mainframe = JFactory::getApplication('site');

$session = JFactory::getSession();
$session->checkToken() or die('Access denied');

That's all good, when script look like above.

But when I init TinyMCE plugin for textarea, using tiny.cloud docs, I have "Access Denied" response from script.


Found answer. The problem, that TinyMCE have own submit function and submit form independently of my ajax. Add

setup: function(editor){
 editor.on('submit', function(){
  return false;

to tinymce init config and tinymce.triggerSave() before Ajax function, and it will be all good.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.