How to pass content in TinyMCE's textarea to a PHP file directly instead of sending via AJAX?
Yes, you can send it without AJAX with an hidden iframe
which has as target
attribute the name
value from iframe
. The original page will not reload. The answer from your server will be loaded in hidden iframe
. In that case, you have to set the iframe
display
to none
.
<iframe name="server_answer" style="display:none"></iframe>
<form method="post" action="dump.php" target="server_answer">
<div id="main">
<div id="container_left">
<textarea id="mytextarea" name="mytext"></textarea>
<input id="submit" type="submit" value="submit">
</div>
<div id="show_right"></div>
</div>
</form>
For your textarea
you have also to write some name
as attribute, for example like name="mytext"
because on the server side you want get the text, which will sended. And because you did not write this name
you can not get it. In your AJAX solution you do it with ajax.send('data='+data);
. In this case data
is like the name of your textarea
.
For your PHP script:
print($_POST["mytext"]); //mytext is name of textarea
Alternative solution
You could also display the submit form as a separate page inside the iframe, and when it gets submitted then the outer page will not reload. This solution does not use AJAX too.