简体   繁体   English

Javascript代码没有进入我的文档就绪侦听器。 (伪造iOS)

[英]Javascript code isn't getting into my document ready listener. (forge iOS)

This is my entire javascript file for the home page of my app. 这是我应用程序主页的整个javascript文件。 Any ideas as to why it never gets into the document ready listener? 关于为什么它从未进入准备就绪的文档监听器的任何想法?

var photos;
forge.request.ajax({
  url: "http://photos-url.com/pics.json",
  dataType: "json",
  success: function(data) {
    photos = data;
  },
  error: function(error) {
    forge.logging.info("Couldn't fetch pics!");
  }
});

//logging output works here

$(function() {
  //logging output doesn't work here
  //I'm trying to append to the html here, but it never gets into this code
});

Cross-domain requests are prohibited for security reasons (same as in desktop browsers). 出于安全原因(与台式机浏览器相同),禁止跨域请求。 You must configure environment to allow requests to your domain. 您必须配置环境以允许向您的域发出请求。 Look at https://trigger.io/docs/current/api/modules/request.html for details. 有关详细信息, 参见https://trigger.io/docs/current/api/modules/request.html

json files are usually allowed to be read from cross domain and even if this one would't be, I still doubt it could affect ready event. 通常允许从跨域读取json文件,即使不是这样,我仍然怀疑它会影响就绪事件。 I'm not using document ready function on my page as I was having simillar issues (it fires few minutes after page is loaded, or doesn't fire at all). 由于出现类似问题,我没有在页面上使用文档就绪功能(页面加载后几分钟触发,或根本不触发)。 You could try window.onload or document.onload events. 您可以尝试window.onload或document.onload事件。 I'd also try to find out how document.readyState behaves and eventually check it manually with interval or try to bind event listener to it. 我还将尝试找出document.readyState的行为方式,并最终以时间间隔手动对其进行检查,或者尝试将事件侦听器与其绑定。

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

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