未捕获的ReferenceError:在get_all中未定义$

时间:2018-07-08 05:17:25

标签: jquery

当我在编码下运行时,我遇到了这个问题

  

未捕获的ReferenceError:在get_all上未定义$

我已经成功链接了jquery文件和CSS文件。我不知道为什么我已经尝试了3天。但无法得到答案。请有人修复此问题。它对我有帮助。我已经在到目前为止尝试过的内容下面附加了代码。

 <script src="bower_components/jquery/dist/jquery.min.js"></script>   
   <script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>    
     <script src="bower_components/jquery.validate.min.js"></script>
<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
   <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
    <script src="bower_components/jquery.validate.min.js"></script>

    <div class="col-sm-8">
            <div class="col s12 m6 offset-m4">
                <div class="panel-heading">
                    <h3 class="panel-title">Current Team Members</h3>
                </div>
                <div class="panel-body">

                    <table id="tbl-projects" class="table table-striped table-bordered" cellspacing="0"
                           width="100%">
                        <thead>
                        <tr>

                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>

                        </tr>

                    </table>
                </div>
            </div>

        </div>
    </div>



    <script>

    get_all();
     function get_all() {

            $('#tbl-projects').dataTable().fnDestroy();
            $.ajax({
                url: "all_category.php",
                type: "GET",
                dataType: "JSON",

                success: function (data) {


                    $('#tbl-projects').dataTable({
                        "aaData": data
                        ,
                        "scrollX": true,
                        "aoColumns": [
                            {"sTitle": "Category", "mData": "catname"},
                            {
                                "sTitle": "Status","mData": "status", "render": function (mData, type, row, meta) {
                                if (mData == 1) {
                                    return '<span class="label label-info">Active</span>';
                                }
                                else if (mData == 2) {
                                    return '<span class="label label-warning">Deactive</span>';
                                }
                            }
                            },

                            {
                                "sTitle": "Edit",
                                "mData": "id",
                                "render": function (mData, type, row, meta) {



                                    return '<button class="btn btn-xs btn-success" onclick="get_project_details(' + mData + ')">Edit</button>';
                                }
                            },
                            {
                                "sTitle": "Delete",
                                "mData": "id",
                                "render": function (mData, type, row, meta) {

                                    return '<button class="btn btn-xs btn-primary" onclick="RemoveTeam(' +  mData + ')">Delete</button>';



                                }
                            }

                        ]

                    });
                },
                error: function (xhr) {
                    console.log('Request Status: ' + xhr.status  );
                    console.log('Status Text: ' + xhr.statusText );
                    console.log(xhr.responseText);
                    var text = $($.parseHTML(xhr.responseText)).filter('.trace-message').text();
                    // console.log(text)

                }
            });
        }

    </script>

1 个答案:

答案 0 :(得分:0)

将jquery.js放在脚本标签之前,它将起作用。