0

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

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

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().

<?php
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');
$mainframe->initialise();

$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.

0

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.

  • Please accept your answer so that this page is deemed resolved by the system and it stops getting "bumped". – mickmackusa Aug 11 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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