请帮忙,我正在尝试制作一个模态,但是它不起作用 当我单击保存时,模态不会隐藏 当我单击编辑时,模态不显示 当我将所有函数放在document.ready函数之外时,所有模态都不会显示任何错误。但是,当我将其放入document.ready函数中时,所有模式都无法正常工作。当我使用控制台时,我得到了错误 $(...)。modal不是函数
这是我使用jquery的脚本
jQuery.noConflict();
jQuery(document).ready(function($){
load_data_response_gateway();
var mytable = $('#mydata').DataTable();
var csrf_hash = '<?php echo $this->security->get_csrf_hash()?>';
function check_response_gateway($rcode){
var result="";
var id_response_gateway=$rcode;
$.ajax({
//some ajax function
});
return result;
}
//加载数据
function load_data_response_gateway(){
$.ajax({
type : 'ajax',
url : '<?php echo base_url()?>base_setup/response_gateway/get_data_response_gateway',
async : false,
data : {'<?php echo $this->security->get_csrf_token_name()?>':csrf_hash},
dataType : 'json',
success : function(data){
csrf_hash = data.csrf_hash;
if (data.rCode == '00') {
var html = '';
var i;
var no=0;
var data_delete='';
for(i=0; i<data.result.length; i++){
no=i+1;
data_delete = [data.result[i].oid, data.result[i].id_response_gateway];
html += '<tr>'+
'<td style="text-align: center;">'+no+'</td>'+
'<td style="text-align: center;">'+data.result[i].id_response_gateway+'</td>'+
'<td style="text-align:center;">'+
'<a href="javascript:;" class="btn btn-info btn-xs item_edit" data="'+ data.result[i].oid+'"> <span class="fa fa-edit"></span> </a>'+' '+
'<a href="javascript:;" class="btn btn-danger btn-xs item_delete" data="'+[data_delete]+'"> <span class="fa fa-trash"></span> </a>'+
'</td>'+
'</tr>';
}
$('#show_data').html(html);
}
else{
$('#show_data').html('');
}
console.clear();
}
});
}
这是我的保存脚本,
$('#btn_save').on('click',function(){
var id_response_gateway = $('#id_response_gateway_add').val();
$.ajax({
type : "POST",
url : "<?php echo base_url('base_setup/response_gateway/action_insert_response_gateway')?>",
dataType : "JSON",
data : {'<?php echo $this->security->get_csrf_token_name()?>':csrf_hash, id_response_gateway:id_response_gateway},
success : function(data){
csrf_hash = data.csrf_hash;
if (data.rCode == '00') {
$('[name="id_response_gateway_add"]').val("");
$('#ModalAdd').modal('hide');
swal("SUKSES!", 'Data Berhasil Disimpan', "success");
//$('#mydata').DataTable().fnClearTable();
load_data_response_gateway();
}else if (data.rCode == 'bb_03' ) {
swal("Warning!", data.check_validation , "error");
}else{
check_response_gateway(data.rCode);
}
}
});
return false;
});
});
//关闭文档准备功能
<!-- call jquery-->
<script type="text/javascript" src="<?php echo base_url().'assets/jquery/jquery-3.3.1.min.js';?>"></script>
<script type="text/javascript" src="<?php echo base_url().'assets/jquery/jquery-ui-1.12.1/jquery-ui.min.js';?>"></script>
<!-- <script type="text/javascript" src="<?php echo base_url().'assets/jquery/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.js';?>"></script>
-->
<!-- call DatePicker-->
<link rel="stylesheet" href="<?php echo base_url().'assets/admin/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css';?>">
<script type="text/javascript" src="<?php echo base_url().'assets/admin/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js';?>"></script>
<!-- call datatable -->
<link rel="stylesheet" type="text/css" href="<?php echo base_url().'assets/DataTables/datatables.min.css';?>"/>
<script type="text/javascript" src="<?php echo base_url().'assets/DataTables/api/jquery-3.3.1.js';?>"></script>
<script type="text/javascript" src="<?php echo base_url().'assets/DataTables/api/jquery.dataTables.min.js';?>"></script>
<script type="text/javascript" src="<?php echo base_url().'assets/DataTables/datatables.min.js';?>"></script>
现在真的需要任何帮助。