【发布时间】:2023-02-11 01:49:06
【问题描述】:
我已经制作了简单的 CRUD Laravel,然后我尝试在多个表中制作具有搜索功能的简单 ORM。 当我在我的数据结果中使用 jQuery 时出现问题,我收到错误:
$.ajax not defined
这是我的results.js:
$(document).ready(function () {
...
$.ajax({
...
});
});
这是我的layout.blade.php:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>NCI ORM App Example</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
</head>
<body>
<style>
...
</style>
<div class="container">
@yield('content')
</div>
<script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha384-xxxxxxxxxxxxxxxx" crossorigin="anonymous" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.3.slim.min.js" integrity="sha384-xxxxxxxxxxxxxxxx" crossorigin="anonymous" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" type="text/js"></sc>
<script type="text/javascript" src="{{ asset('results.js') }}"></script>
</body>
</html>
我试图生成一个新的完整性并在<script>中添加typ="text/javascript"并将$.ajax更改为jQuery.ajax,仍然无法正常工作。
提前致谢。
【问题讨论】:
-
在标头中移动 jquery 库,以便它在 ajax 调用之前加载