Laravel Uncaught ReferenceError:$未定义

时间:2018-05-16 08:33:38

标签: javascript jquery ajax laravel

我将背包Laravel的@extends('backpack :: layout')与Ajax CRUD结合在一起,我遇到了标题中提到的问题。

这是刀片文件。

<script type="text/javascript">
    $(document).ready(function() {
     $('#domain_table').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "{{ route('ajaxdata.getdata') }}",
            "columns":[
                { "data": "Domain" },
                { "data": "Registrar" },
                { "data": "Login_ID" },
                { "data": "Password" },
                { "data": "New_Mobile" },
                { "data": "Mobile" },
                { "data": "Email" },
                { "data": "Email_Password" },
                { "data": "action", orderable:false, searchable: false}
            ]
        });
         });
</script>

这是@extends('backpack :: layout')

中列出的库的一部分
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>

2 个答案:

答案 0 :(得分:3)

试试这个

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>    
<script type="text/javascript">
    $(document).ready(function() {
     $('#domain_table').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "{{ route('ajaxdata.getdata') }}",
            "columns":[
                { "data": "Domain" },
                { "data": "Registrar" },
                { "data": "Login_ID" },
                { "data": "Password" },
                { "data": "New_Mobile" },
                { "data": "Mobile" },
                { "data": "Email" },
                { "data": "Email_Password" },
                { "data": "action", orderable:false, searchable: false}
            ]
        });
         });
</script>

在实际使用 $ 之前,您必须声明jquery.min.js

答案 1 :(得分:1)

尝试使用jQuery代替$ jQuery(document)而不是$(document)