关闭

举报

  • 提交
    首页 > 致富技术 > 正文
    购物车
    0

    $.ajax 技巧,代码结构,操作时控制按钮状态,防止多次点击

    信息发布者:宇晨网络
    2017-09-22 15:51:26   转载

    $.ajax 技巧:


    $.ajax({

    url: 'index.php?route=sale/order/history&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>',

    type: 'post',

    dataType: 'html',

    data: 'order_status_id=' + encodeURIComponent($('select[name='order_status_id']').val()) + '&notify=' + encodeURIComponent($('input[name='notify']').attr('checked') ? 1 : 0) + '&append=' + encodeURIComponent($('input[name='append']').attr('checked') ? 1 : 0) + '&comment=' + encodeURIComponent($('textarea[name='comment']').val()),

    beforeSend: function() {

    $('.success, .warning').remove();

    $('#button-history').attr('disabled', true);

    $('#history').prepend('<div class"attention"><img src="view/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');

    },

    complete: function() {

    $('#button-history').attr('disabled', false);

    $('.attention').remove();

    },

    success: function(html) {

    $('#history').html(html);

    $('textarea[name='comment']').val('');

    $('#order-status').html($('select[name='order_status_id'] option:selected').text());

    }

    });


    打赏捐赠
    0
    !我要举报这篇文章
    声明 本文由村网通注册会员上传并发布,村网通仅提供信息发布平台。文章仅代表作者个人观点,不代表村网通立场。本文如涉及侵权请及时联系我们,我们将在24小时内予以删除!