[英]Trying to link a local Javascript file to HTML document but in the browser, I receive a Failed to load resource error
I'm trying to link a javascript file to my html document. 我正在尝试将javascript文件链接到我的html文档。
I'm following the instructions on http://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI/#demo-days-range to select multiple dates from a calendar as input in a form. 我正在按照http://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI/#demo-days-range上的说明从日历中选择多个日期作为表单中的输入。
It says "You include both jQuery and jQuery UI (with datepicker module included!) javascript files to your HTML page, and right after that, include MultiDatesPicker". 它说:“您在HTML页面中同时包含了jQuery和jQuery UI(包括datepicker模块!)JavaScript文件,并在其后添加了MultiDatesPicker”。
<script src="https://code.jquery.com/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="jquery-ui.multidatespicker.js"</script>
Which I have done. 我已经做了。
Note jquery-ui.multidatespicker.js is in my local project directory as it's own file not in any folders. 注意jquery-ui.multidatespicker.js在我的本地项目目录中,因为它是自己的文件,不在任何文件夹中。 You can download a zip file on the github page where this file is included.
您可以在包含此文件的github页面上下载一个zip文件。
Then I call the multidatespicker function in the head of the document. 然后,我在文档的开头调用multidatespicker函数。
<script type="text/javascript">
$(function() {
$('#mdp-demo').multiDatesPicker();
});
</script>
And finally within the body you write your html input id to be used in the function 最后,在正文中编写要在函数中使用的html输入id
<input id="mdp-demo">
When I run this in the browser I get an error "Failed to load resource: the server responded with a status of 404 (NOT FOUND)" for jquery-ui.multidatespicker.js:1. 在浏览器中运行此脚本时,对于jquery-ui.multidatespicker.js:1,出现错误“无法加载资源:服务器响应状态为404(未找到)”。
If you scroll down to the demos on the multiple dates github page and go to "Form input". 如果您向下滚动到多个日期github页面上的演示,然后转到“表单输入”。 That is what i'm trying to achieve.
那就是我想要达到的目标。 The problem is that my jquery-ui.multidatespicker.js script search isn't finding the script and therefore doesn't recognize the .multiDatesPicker() function.
问题是我的jquery-ui.multidatespicker.js脚本搜索找不到该脚本,因此无法识别.multiDatesPicker()函数。
Any suggestions as to what I'm doing wrong? 关于我在做什么错的任何建议吗?
You should use CDN link for multidatespicker 您应该将CDN链接用于multidatespicker
<script src="https://cdn.jsdelivr.net/npm/jquery-ui-multidatespicker@1.6.6/jquery-ui.multidatespicker.js"></script>
If you want to use <script src="jquery-ui.multidatespicker.js"</script>
you need download file an put at same HTML folder and it will work. 如果您想使用
<script src="jquery-ui.multidatespicker.js"</script>
,则需要在同一个HTML文件夹中放置一个put文件,该文件才能正常工作。 Also note that you missing > for open tag. 另请注意,您缺少>的开放标签。
$(function() { $('#mdp-demo').multiDatesPicker(); });
<script src="https://code.jquery.com/jquery.min.js"></script> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="https://cdn.jsdelivr.net/npm/jquery-ui-multidatespicker@1.6.6/jquery-ui.multidatespicker.js"></script> <input id="mdp-demo" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.