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.

1 Answer 1

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.

2
  • Please accept your answer so that this page is deemed resolved by the system and it stops getting "bumped". Aug 11, 2019 at 7:54
  • you have been on this site in the last couple of weeks. Please take a second to award your answer the green tick. Aug 13, 2020 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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