开发者

jQuery TinyMCE fails on AJAX

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 fir开发者_运维百科st 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;

});  


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜