1. <legend id='qtVZd'><style id='qtVZd'><dir id='qtVZd'><q id='qtVZd'></q></dir></style></legend>
  2. <i id='qtVZd'><tr id='qtVZd'><dt id='qtVZd'><q id='qtVZd'><span id='qtVZd'><b id='qtVZd'><form id='qtVZd'><ins id='qtVZd'></ins><ul id='qtVZd'></ul><sub id='qtVZd'></sub></form><legend id='qtVZd'></legend><bdo id='qtVZd'><pre id='qtVZd'><center id='qtVZd'></center></pre></bdo></b><th id='qtVZd'></th></span></q></dt></tr></i><div id='qtVZd'><tfoot id='qtVZd'></tfoot><dl id='qtVZd'><fieldset id='qtVZd'></fieldset></dl></div>
      <bdo id='qtVZd'></bdo><ul id='qtVZd'></ul>

      <tfoot id='qtVZd'></tfoot>

      <small id='qtVZd'></small><noframes id='qtVZd'>

    1. 带有 jquery 的仪表板跨域 AJAX

      时间:2023-09-07
        <tfoot id='RIw6F'></tfoot>
          • <bdo id='RIw6F'></bdo><ul id='RIw6F'></ul>
            <legend id='RIw6F'><style id='RIw6F'><dir id='RIw6F'><q id='RIw6F'></q></dir></style></legend>

              <i id='RIw6F'><tr id='RIw6F'><dt id='RIw6F'><q id='RIw6F'><span id='RIw6F'><b id='RIw6F'><form id='RIw6F'><ins id='RIw6F'></ins><ul id='RIw6F'></ul><sub id='RIw6F'></sub></form><legend id='RIw6F'></legend><bdo id='RIw6F'><pre id='RIw6F'><center id='RIw6F'></center></pre></bdo></b><th id='RIw6F'></th></span></q></dt></tr></i><div id='RIw6F'><tfoot id='RIw6F'></tfoot><dl id='RIw6F'><fieldset id='RIw6F'></fieldset></dl></div>
                <tbody id='RIw6F'></tbody>

              1. <small id='RIw6F'></small><noframes id='RIw6F'>

                本文介绍了带有 jquery 的仪表板跨域 AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                大家好,我正在为 Apple 的 Dashboard 开发一个小部件,但在尝试使用 jquery 的 ajax 函数从我的服务器获取数据时遇到了问题.这是我的 JavaScript 代码:

                Hey everyone, I'm working on a widget for Apple's Dashboard and I've run into a problem while trying to get data from my server using jquery's ajax function. Here's my javascript code:

                $.getJSON("http://example.com/getData.php?act=data",function(json) { 
                    $("#devMessage").html(json.message)
                    if(json.version != version) {
                        $("#latestVersion").css("color","red")
                    }
                    $("#latestVersion").html(json.version)
                })
                

                服务器用这个 json 响应:

                And the server responds with this json:

                {"message":"Hello World","version":"1.0"}
                

                但由于某种原因,当我运行这个时,小部件上的字段不会改变.通过调试,我了解到该小部件甚至不会向服务器发出请求,因此我认为 Apple 设置了某种外部 URL 块.不过我知道这不是真的,因为许多小部件都会打电话回家检查更新.

                For some reason though, when I run this the fields on the widget don't change. From debugging, I've learned that the widget doesn't even make the request to the server, so it makes me think that Apple has some kind of external URL block in place. I know this can't be true though, because many widgets phone home to check for updates.

                有人对可能出现的问题有任何想法吗?

                Does anyone have any ideas as to what could be wrong?

                此外,此代码在 Safari 中运行良好.

                Also, this code works perfectly fine in Safari.


                根据 Luca 的要求,下面是正在运行的 PHP 和 Javascript 代码:


                As requested by Luca, here's the PHP and Javascript code that's running right now:

                PHP:

                echo $_GET["callback"].'({"message":"Hello World","version":"1.0"});';
                

                Javascript:

                Javascript:

                function showBack(event)
                {
                var front = document.getElementById("front");
                var back = document.getElementById("back");
                
                if (window.widget) {
                    widget.prepareForTransition("ToBack");
                }
                
                front.style.display = "none";
                back.style.display = "block";
                stopTime();
                if (window.widget) {
                    setTimeout('widget.performTransition();', 0);
                }
                $.getJSON('http://nakedsteve.com/data/the-button.php?callback=?',function(json) { 
                    $("#devMessage").html(json.message)
                    if(json.version != version) {
                        $("#latestVersion").css("color","red")
                    }
                    $("#latestVersion").html(json.version)
                })
                }
                

                推荐答案

                在 Dashcode 中单击 Widget Attributes 然后 Allow Network Access 确保选中该选项.我已经构建了一些拒绝工作的东西,这就是解决方案.

                In Dashcode click Widget Attributes then Allow Network Access make sure that option is checked. I've built something that simply refused to work, and this was the solution.

                这篇关于带有 jquery 的仪表板跨域 AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:CKEditor,初始化使用 insertElement 添加的小部件 下一篇:JSONP 与 IFrame?

                相关文章

                <small id='OGyWF'></small><noframes id='OGyWF'>

                    <legend id='OGyWF'><style id='OGyWF'><dir id='OGyWF'><q id='OGyWF'></q></dir></style></legend>
                    • <bdo id='OGyWF'></bdo><ul id='OGyWF'></ul>

                  1. <tfoot id='OGyWF'></tfoot>

                    <i id='OGyWF'><tr id='OGyWF'><dt id='OGyWF'><q id='OGyWF'><span id='OGyWF'><b id='OGyWF'><form id='OGyWF'><ins id='OGyWF'></ins><ul id='OGyWF'></ul><sub id='OGyWF'></sub></form><legend id='OGyWF'></legend><bdo id='OGyWF'><pre id='OGyWF'><center id='OGyWF'></center></pre></bdo></b><th id='OGyWF'></th></span></q></dt></tr></i><div id='OGyWF'><tfoot id='OGyWF'></tfoot><dl id='OGyWF'><fieldset id='OGyWF'></fieldset></dl></div>