简体   繁体   English

这个JavaScript错误是什么意思?

[英]What does this JavaScript error mean?

Using the “Venkman” JavaScript debugger for Mozilla and getting the following error: 使用Mozilla的“ Venkman” JavaScript调试器并得到以下错误:

 XML Parsing Error: not well-formed
    Location: x-jsd:source?location=http%3A%2F%2F192.168.1.150%2Fscript.js&instance=337
    Line Number 557, Column 50:<line><margin x='t'> - </margin><num>  554</num> ��      valid = false;</line>

Functions works but I don't understand the error. 函数有效,但我不理解该错误。
Any help is appreciated. 任何帮助表示赞赏。 Thanks. 谢谢。

function ValidateCheckBoxes() 
{
   var valid;
   $(document).ready(function(){

      if($('input[@name=boxesA]:checked').size() == 0)
      {
         valid = false; 
      }
      else
      {
         valid = true;
      }
   });

   return valid;      
}

I'd say that you've encountered a bug in the “Venkman” JavaScript debugger ... you have some character in your code that is not in the same codepage as the rest of your script. 我想说您在“ Venkman” JavaScript调试器中遇到了一个错误……您的代码中有些字符与其余脚本不在同一代码页中。 ( valid=false; ) valid=false;

When Venkman tries to format your javascript to display it, whatever it is using to parse the XML it generates throws an error, and that's what you are seeing. 当Venkman尝试格式化JavaScript以显示它时,无论它用来解析它生成的XML的什么,都会引发错误,这就是您所看到的。

Try taking that line out with whatever editor you are using and re-writing it. 尝试使用任何编辑器删除该行,然后重新编写。 That should solve the problem. 那应该解决问题。

You probably have some weird character encoding of a line break or similar, judging from valid = false; valid = false;判断,您可能会有一些奇怪的换行符或类似字符编码 valid = false; . Check the file encoding, remove any white-space before that line, and create a new line break. 检查文件编码,删除该行之前的所有空白,然后创建一个新的换行符。

Edit : Sorry for the almost identical answer as @Sean Vieira made, was also checking the function with JsLint, and it came out (pretty much) without complaints, but suggested that you use === instead of == when comparing to 0 编辑 :对不起,与@Sean Vieira所做的回答几乎相同,也正在使用JsLint检查该函数,并且结果(几乎没有问题),但建议您在与0比较时使用===而不是==

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

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