[英]JavaScript variable assignment not working
I have run in to a stupid problem... I declared a new variable called leadingZero. 我遇到了一个愚蠢的问题...我声明了一个名为LeadingZero的新变量。 I save the modified .js file and run the project with a breakpoint on the leadingZero assignment and in watcher window it says its undefined after passing this line, but all the other declarations here are working fine and I can see the assigned values.
我保存了修改后的.js文件,并在LeadingZero分配上运行带有断点的项目,并且在监视程序窗口中,在通过此行后显示未定义的断点,但是此处的所有其他声明都可以正常工作,并且可以看到分配的值。 needless to say the getObject call does not work now.
不用说getObject调用现在不起作用。
var leadingZero = 0; //new variable
var chkActive;
var chkSubscribe;
var hdnItem = getObject('hdnItemCounter');
var ItemCount = parseInt(hdnItem.value) + 1;
for (intCounter = 2; intCounter <= ItemCount; intCounter++) {
chkActive = getObject('dgrProductList_ctl0' + leadingZero + intCounter + '_chkActive');
}
Check this http://jsfiddle.net/DHDsE/ 检查此http://jsfiddle.net/DHDsE/
Not getting the undefined problem tho, but having to add toString() to leadingZero for it to render in the console.log, so maybe that's your issue too. 并没有解决未定义的问题,而是必须将toString()添加到LeadingZero才能在console.log中进行渲染,所以也许这也是您的问题。
You did set the breakpoint on the line below, didn't you? 您确实在下面的行上设置了断点,不是吗?
Because if you set it on the line var leadingZero = 0;
因为如果在行上设置
var leadingZero = 0;
it halts before the line is evaluated, which explains the undefined value in the watcher. 在评估该行之前它会暂停,这解释了观察程序中的未定义值。
Also, as gillesc pointed out, your leadingZero
must be a string, otherwise you're adding up intCounter
and leadingZero
, rather than concatenating them. 另外,正如gillesc指出的那样,您的
leadingZero
必须是字符串,否则您leadingZero
intCounter
和leadingZero
,而不是将它们串联在一起。
The problem seemed to be changes to the js were not loaded in ie cache. 问题似乎是对js的更改未在即缓存中加载。 even after closing ie, rebuilding the project and running again, I still need to hit ctrl+f5 on the page to load the new javascript
即使关闭后,即重建项目并再次运行,我仍然需要在页面上按ctrl + f5来加载新的javascript
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.