【问题标题】:Windows 8 metro app - can’t load remote web content in the local contextWindows 8 Metro 应用程序 - 无法在本地上下文中加载远程 Web 内容
【发布时间】:2014-02-22 10:00:12
【问题描述】:

我一直在 APPHOST9601:无法加载 http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js。应用无法在本地上下文中加载远程 Web 内容

请注意,我只有 14 岁,对此完全陌生。只是在尝试做点什么。

我四处寻找,找不到解决方案。 该项目是一个从 bter.com api 提取数据并显示的跟踪器。没有什么花哨。 在正常的 index.html 上效果惊人。 Windows 8 应用程序,我这辈子都不能让它工作:(。我一直在这只是在一个普通的 index.html 文件中布置东西,现在我的应用程序几乎要退出了。 这是我的代码 - home.html 文件

更新:似乎我已经想通了。 创建新的 .js 文件,添加脚本,调用它,一切都很好。所以它看起来。敲木头。 - 仍然愿意接受您可能提供的任何帮助/支持

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>homePage</title>

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

    <link href="/css/default.css" rel="stylesheet" />
    <link href="/pages/home/home.css" rel="stylesheet" />
    <script src="/pages/home/home.js"></script>
    <script src="/js/jquery-2.0.0.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


</head>
<body>
    <!-- The content that will be loaded and displayed. -->
    <div class="fragment homepage">
        <header aria-label="Header content" role="banner">
            <button class="win-backbutton" aria-label="Back" disabled type="button"></button>
            <h1 class="titlearea win-type-ellipsis">
                <span class="pagetitle">Welcome to App1!</span>
            </h1>
        </header>
        <section aria-label="Main content" role="main">
            <p>Content goes here.</p>
            Current Exchange Rate: <div id="ticker1"></div>


                $(function () {
                    startRefresh();
                });

                function startRefresh() {
                    setTimeout(startRefresh, 10000);
                    var turl = 'https://bter.com/api/1/ticker/doge_btc';
                    $.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20json%20where%20url%3D%22' + encodeURIComponent(turl) + '%22&format=json', function (data) {
                        jQuery('#ticker1').html(data['query'].results.json.last);
                        jQuery('#ticker1').append(' DogeCoin');
                    });
                }

            //blah ignore after
            <button id="buttonYouWantToClick">Button</button>
<div id="result"></div>



        </section>
    </div>
</body>
</html>

【问题讨论】:

    标签: jquery windows sdk microsoft-metro


    【解决方案1】:

    Windows 8 不允许应用在本地上下文中加载远程 Web 内容。因此,您应该下载 Jquery 文件,然后将其添加到您的代码中。 而且在windows 8 应用开发中总是使用jquery 2.0 或更高版本,因为以前的版本不支持;不支持windows 8 应用程序导致它与Winjs 冲突。 要在代码中成功运行 jquery,请阅读本文。这对我也很有帮助。希望对你有帮助

    http://mywindows8apps.com/2012/10/27/how-to-use-jquery-in-a-windows-8-application/

    【讨论】:

    • Jquery 2.1 导致 HTML1701 - 无法添加动态内容错误。所以你只需要使用 jquery 2.0.x。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多