javascript - HTML 脚本不加载 JavaScript 文件

标签 javascript jquery html ios uiwebview

我正在尝试在我的 iOS xcode 项目的 UIWebview 中显示饼图,因为我将 jqplot 与 HTML、CSS 和 JavaScript 结合使用,我面临的问题是 JavaScript 文件“devicepiechart.js”正在从 html 加载。

<!DOCTYPE html>

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />
<script>
            function load()
            {
                alert("I am an loading scripts!");
            }
        </script>

<script src="devicepiechart.js"></script>
</head>
<body onload= "load()">
</body>
</html>

load() 函数警报正确显示,没有任何问题。我可以检测到我的 .js 文件没有加载,因为我的 .js 文件中也有 alert("string"); 函数用于调试。

已更新 devicepiechart.js,我希望外部 .js 文件不会有任何错误,因为我有这个 http://www.jqplot.com/tests/pie-donut-charts.php 的源代码

$(document).ready(function()
      {
              alert("good");
              var data = [
                          ['Heavy Industry', 12],['Retail', 9], ['Light Industry', 14],
                          ['Out of home', 16],['Commuting', 7], ['Orientation', 9]
                          ];
              var plot1 = jQuery.jqplot ('chart1', [data],
                                         {
                                         seriesDefaults: {
                                         // Make this a pie chart.
                                         renderer: jQuery.jqplot.PieRenderer,
                                         rendererOptions: {
                                         // Put data labels on the pie slices.
                                         // By default, labels show the percentage of the slice.
                                         showDataLabels: true
                                         }
                                         }, 
                                         legend: { show:true, location: 'e' }
                                         }
                                         );
              });

最佳答案

在其他 js 加载之前包含 jquery

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

关于javascript - HTML 脚本不加载 JavaScript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20369967/

相关文章:

javascript - jQuery 显示属性没有改变,但其他属性是

javascript - 根据base.href或位置生成规范/真实URL

javascript - 当 vue js radio 改变时执行 Action

jquery - Select2 - 未找到匹配项时禁用提交按钮

javascript - Datatables 和 ColumnFilterWidgets 的重置链接不会重新填充选择

jquery - 如何删除列表中的 "Select"

javascript - 现有函数作为 Array.forEach 的回调

javascript - 在 Prototype 中使用自己的 AJAX 请求回调方法

actionscript-3 - Apache 中 Flex 的 future

javascript - Jquery 自定义滚动条(Malihu - mCustomScrollBar)不起作用