0

我想访问我在模式内的数据表内的按钮,但是当我想访问它时,即使我更改了“a”标签的 id 或类,也不会加载任何警报、ajax url 或任何东西。我该如何解决?这个 ajax 我知道它不会在控制台中加载和出错,但它也会显示它..

阿贾克斯

    $(function(event) {
  URL_GET_VIEW_SEARCH_PRODUCT = BASE_URL + 'sale/sales/getViewSearch';
  URL_GET_DATATABLE = BASE_URL + 'sale/sales/datatable';
  URL_SEARCH_PRODUCT = BASE_URL + 'sale/sales/search_product';
  $('#btn-search').click(function (e) {
     BootstrapDialog.show({
        title: 'Search Product',
        message: function(dialog) {
           var $message = $('<div></div>');
           var pageToLoad = dialog.getData('pageToLoad');
           $message.load(pageToLoad);
           return $message;
        },
        data: {
           pageToLoad: URL_GET_VIEW_SEARCH_PRODUCT
        },
        onshown: function(dialog){
           $('#example').DataTable({
                lengthChange: false,
                responsive: true,
                ajax: {
                  url: URL_GET_DATATABLE,
                  type: 'POST',
                },
                columnDefs: [{
                targets: 4,
                data: null,
                defaultContent: "<a href='#'><span class='glyphicon glyphicon-plus'></span></a>"
              }],
           });
        }
     });
  });
   $('#search').typeahead({
      source: function (query,process) {
        $.ajax({
            url: URL_SEARCH_PRODUCT,
            type: 'POST',
            data: {query: query},
            dataType: 'json',
            async: true,
            success: function (data) {
              console.log(data);
              process(data);
            }
        });
      }
   });

  $('#example tbody').on('click', 'a', function(event) {
      $.ajax({
        url: '/path/to/file',
        type: 'default GET (Other values: POST)',
        dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
        data: {param1: 'value1'},
      })
   });
});

表视图

<table id="example" class="table table-bordered table-striped" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Code</th>
            <th>Description</th>
            <th>Stock</th>
            <th>Price</th>
            <th></th>
        </tr>
    </thead>
</table>
4

0 回答 0