3

I've got this weird problem with my TinyMCE. I've made a FORM with the tinyMCE editor, no errors returned, works fine. But, when i make an ajax call, inserting some text into the database the text won't be placed in the database. However, if i click the button twice, the first row get's inserted without the text, and the second WITH the text.

Dose any one know why this happens? or have experience with it? maybe it's a common problem?

$('#newsWrite').submit(function() {

    var testing = $('#newsWrite').serialize();

    alert(testing);

    $('#box_load').show();
    $('#box_error').html('');
    $('#box_ok').html('');

    $.post('js/ajax/writeNews.php', $('#newsWrite').serialize(), function(data) {
        alert(testing);
        $('#box_load').hide();

        if(data.error == 'false') {
            $('#box_ok').append(data.errorMessage);
            $('#box_ok').fadeIn();
        }

        if(data.error == 'true') {
            $('#box_error').append(data.errorMessage);
            $('#box_error').fadeIn();
        }

    },'json');

    return false;

});  
mu is too short
  • 426,620
  • 70
  • 833
  • 800
Dexty
  • 1,462
  • 6
  • 17
  • 27

1 Answers1

3

Hard to really determine what is happening as there are too many variables involved. What I like to do is setup alert(); with friendly messages and try to track down the problem. In your case I would do that before ajax call is made and after and then work my way up to when the form is about to be submitted. You want to use alert to check if the data actually exists when the form is about to be submitted

Adil
  • 3,183
  • 5
  • 28
  • 30
  • I've done what you said, as i said in the first post. The data doesn't get sent on the first request, but on the second everything works. – Dexty Mar 19 '11 at 03:50
  • 1
    Looks like i've found the issue, the textarea is no longer a form, but iFrame (since tinymce dose this) anyway, i've fixed the issues now! Thanks! – Dexty Mar 19 '11 at 03:57
  • @RonnieMinimeAarebrot - how did you fix the problem? I'm having a similar issue. – Andrew Jun 18 '12 at 23:43
  • For anyone looking for the answer, you need to make a call to tinyMCE.triggerSave(); before calling .serialize(). As per this SO post http://stackoverflow.com/questions/2122085/problem-jquery-and-tinymce-textarea-value-doesnt-submit – Andrew Jun 18 '12 at 23:50