Question

I'm working with html/php/ajax/jquery and today I pointed out a little issue that is driving me crazy.

I've got an html form:

<form method="POST" enctype="multipart/form-data" name="myForm" id="myForm" action="">
    <label class="form-label">Nome</label>
    <input name="nome" type="text" class="form-control"><br>
    <label class="form-label">Descrizione</label>
    <textarea name="descrizione" id="text-editor" placeholder="" class="form-control" rows="10"></textarea>
    <label class="form-label">Stato</label>
    <select name="stato" id="source" style="width:30%">
        <option value="1">Abilitato</option>
        <option value="0">Disabilitato</option>
    </select>
    <h4>Foto profilo</h4>
    <input type="hidden" name="MAX_FILE_SIZE" value="20400000" >  
    <input style="border:0px;" type="file" name="user_foto" id="file"> 
    <div class="form-actions">  
        <div class="pull-right">
            <button type="submit" class="btn btn-success btn-cons"><i class="icon-ok"></i>Inserisci</button>
            <button type="button" class="btn btn-white btn-cons" onclick="window.location.href='index.php'">Indietro</button></a>
        </div>
    </div>
</form>

I'm working with a JQuery+Ajax script that is able to fire a php script without reloading page, and insert form's data into a table in my database:

$(document).ready(function(){
    $('#myForm').on('submit',function(e) {
        var formData = new FormData(this);      
        $.ajax({
            url:'inserisciProfessionisti.php',
            data: formData,
            type:'POST',
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success:function(data){
                window.location = 'listaProfessionisti.php'
            },
            error:function(data){}
        });
        e.preventDefault(); //=== To Avoid Page Refresh and Fire the Event "Click"===
    });
});

Here my php code:

<?php
session_start();
session_cache_limiter('nocache');
if(!isset($_SESSION['mail'])){
    header("location:login.php");
}
include("include/connect.php");
$conn=mysql_connect($HOST, $USER, $PASSWORD);
$db_ok=mysql_select_db($DB, $conn);
$nome=$_POST['nome'];
$descrizione = $_POST['descrizione'];
....
$comando="INSERT INTO professionisti('nome','descrizione',...)VALUES('$nome','$descrizione',...)";
$ris=mysql_query($comando, $conn) or die("Errore connessione database: " . mysql_error());
... 

Everything works like a charm apart textarea content. It seems that textarea content wouldn't be passed to my php script.

Was it helpful?

Solution

Issue solved. I add this onclick="tinyMCE.triggerSave(true,true);" to submit button and everything works like a charm. I think It should be a tinyMCE bug.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top