zoukankan      html  css  js  c++  java
  • js jquery 函数回调

    JS 函数回调

        $('#btn_update').click(function () {
            var table_id = $table.bootstrapTable('getSelections')[0]['id'];
            var url = "/advertisement_list_pager/" + table_id + "/";
            var type = "GET";
            var data = '';
            var result = Base_Ajax(type, url, data);
            console.log(result);
            console.log(result.ajax_status);
            if (result.ajax_status == 200) {
                $('#submit_save_b').hide();
                $('#update_save_b').show();
                $('#Adver_Cell_Modal').modal('show');
                Data_Back(result.ajax_data);
                $('#myModalLabel').text('请更新广告单元,并重新上传文件').css('color','red');
            }
    
        });
        function Base_Ajax(p_type, p_url, p_data) {
            var csrftoken = getCookie('csrftoken');
            var result;
            $.ajax({
                cache: false,
                type: p_type,
                url: p_url,
                //dataType: 'json',
                data: p_data,
                async: false,//这里选择异步为false,那么这个程序执行到这里的时候会暂停,等待
                //数据加载完成后才继续执行
                success: function (data, textStatus, jqXHR) {
                    //获取HTTP状态
                    // console.log(jqXHR.status);
                    // console.log(data);
                    result = {
                        'ajax_status': jqXHR.status,
                        'ajax_data': data
                    };
                },
                error: function (xhr, textStatus) {
                    console.log('错误');
                    console.log(xhr);
                    console.log(textStatus)
                },
                beforeSend: function (xhr, settings) {
                    xhr.setRequestHeader("X-CSRFToken", csrftoken);
                }
            });
    
            return result
        }
  • 相关阅读:
    English trip V1
    English trip M1
    every day a practice —— morning(5)
    English Voice of <<All Of Me>>
    bzoj 3561 DZY Loves Math VI
    luogu P4322 [JSOI2016]最佳团体
    luogu P3264 [JLOI2015]管道连接
    bzoj 5084 hashit
    luogu P6091 原根
    bzoj 5206 [Jsoi2017]原力
  • 原文地址:https://www.cnblogs.com/zhaoyingjie/p/9229102.html
Copyright © 2011-2022 走看看