首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
广告
V2EX
›
问与答
请教个 JS 动态加载代码的问题..
paulw54jrn
·
2014-10-20 19:11:36 +08:00
· 2938 次点击
这是一个创建于 3776 天前的主题,其中的信息可能已经有所发展或是发生改变。
JS新手,项目有需要就硬着头皮上了..
lpTag会在加载时发送ajax请求,然后把vars.send()方法注入到自身.
需要运行以下代码,但是在运行vars.send()的时候send方法还没有被创建. 项目其他要求导致了不能用jQuery的when方法. 用setTimeout()可能过不了code review. 请问下有别的办法吗?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
var send = function(){
var lpTag = lpTag || {}; lpTag.vars = lpTag.vars || []; lpTag.dbs = lpTag.dbs || [];
var arrLPvars = [
{ scope:'page', name:'some-unit', value:'some-value' }
];
lpTag.vars.push(arrLPvars);
lpTag.vars.send();
}
//setTimeout(function(){send();},2000);
view raw
gistfile1.js
hosted with ❤ by
GitHub
目前尚无回复
vars.send
setTimeout
lptag
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
1281 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 20ms ·
UTC 17:50
·
PVG 01:50
·
LAX 09:50
·
JFK 12:50
Developed with
CodeLauncher
♥ Do have faith in what you're doing.