开发者

Displaying message on ajax submission (or data submission) jquery

I have a jquery script in my page as below;

$(function() {
    $('.action_button').click(function() {
        var $button = $(this);
        $.ajax({
            type: 'POST',
            url: 'action.php',
            data: 'id='+ $(this).attr('id'),
            cache: false,
            success: function(result) {
                var $row = $button.closest('tr');
                var $col = $row.find('.clickme2');
                $row.fadeOut('fast', function() {
                    if (result == 'ACTIVATED') {
                      $("#msgbox3").fadeTo(200,0.1,function()
            {
              $(this).html('ACTIVATED').addClass('messageboxerror').fadeTo(900,1);
            });
                        $button.text('Inactivate');
                        $col.text('Active');
               开发者_开发技巧     } else if (result == 'INACTIVATED') {
                      $("#msgbox3").fadeTo(200,0.1,function()
            {
              $(this).html('INACTIVATED').addClass('messageboxerror').fadeTo(900,1);
            });
                        $button.text('Activate');
                        $col.text('Inactive');
                    }
                }).fadeIn();
            }
        });
        return false;
    });
});

this displays a message "ACTIVATED" or "INACTIVATED" on page in a span <span id="msgbox3" style="display:none"></span> . But i want to display a message "Processing" at the time of ajax / data submission, in that same span.. How can i make this possible??

Thanks in advance.. :)

blasteralfred


The Ajax call is asynchronous. Do it before or after

$.ajax({});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜