简体   繁体   English

在 html 页面错误中包含 JS 文件

[英]Including JS file in html page errors

I have this JavaScript code inside an html and PHP page.我在 html 和 PHP 页面中有此 JavaScript 代码。 But I've been told that it will works only if I had an internet connection, so the solution was to make a .JS file and include this file inside the page like that:但是有人告诉我它只有在我有互联网连接时才能工作,所以解决方案是制作一个 .JS 文件并将这个文件包含在页面中,如下所示:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="/clinic form/appoint/dropscript.js">
</script>

Now I got an error while testing the page offline.现在我在离线测试页面时遇到错误。

这些是错误

The JS file is taken from this link: multiple java script in one page error JS文件取自这个链接: multiple java script in a page error

And the final code is:最后的代码是:

$(document).ready(function(){
    $("#Date").change(function(){
        var seldate =$(this).val();
        display_data(seldate);
    });

    // This is the function...
    function display_data(seldate) {

        $("#scheduleDate").html(seldate);
        var dataString = 'seldate='+ seldate;
            $.ajax({
            type: "POST",
            url: "getdata.php",
            data: dataString,
            cache: false,
            success: function(data) {
                $("#Schedule").html(data);
            } 
        });

    }
    // Now here is the real code for retaining your Date...
    /*<?php
    if (!empty($_GET['date'])) {
        ?>
    display_data('<?php echo $_GET["date"]; ?>')
        <?php
    }
    ?>*/
    document.getElementById('Date').value = '<?php echo @$_GET["date"]; ?>';

});



$(document).ready(function(){
    $("#Name").change(function(){
        var selname =$(this).val();
        display_name(selname);
    });

    // This is the function...
    function display_name(selname) {
        $("#scheduleName").html(selname);
        var dataString = 'selname='+ selname;
        $.ajax({
            type: "POST",
            url: "getdatabyname.php",
            data: dataString,
            cache: false,
            success: function(data) {
                $("#Schedule").html(data);
            } 
        });
    }
});// JavaScript Document

PS I am totally new to JS and I am experimenting. PS我对JS完全陌生,我正在试验。

Go to https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js , hit CTRL+S, move saved file to your project's directory and then include it as you did with dropscript.js.转到https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js ,按 CTRL+S,将保存的文件移动到您的项目目录,然后像使用 dropscript 一样包含它。 js。

Also do the same with the font if you need it.如果需要,也可以对字体执行相同的操作。 Include it into your CSS file using @font-face .使用@font-face其包含到您的 CSS 文件中。 More information: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face更多信息: https : //developer.mozilla.org/en-US/docs/Web/CSS/@font-face

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM