我有一些jQuery代码,没有它在文档中通过验证很好,但它在它导致错误。有问题的代码是在这里:W3 xHTML验证jQuery代码错误!
$.ajax({
type: "GET",
url: "data.xml",
dataType: "xml",
success: function(xml) {
//Update error info
errors = $(xml).find("Errors").find("*").filter(function()
{
return $(this).children().length === 0;
});
if (errors.length == 0)
{
statuscontent = "<img src='/web/resources/graphics/accept.png' alt='' /> System OK";
}
else
{
statuscontent = "<img src='/web/resources/graphics/exclamation.png' alt='' /> "+errors.length+" System error"+(errors.length>1?"s":"");
}
$("#top-bar-systemstatus a").html(statuscontent);
//Update timestamp
$("#top-bar-timestamp").html($(xml).find("Timestamp").text());
//Update storename
$("#top-bar-storename").html("Store: "+$(xml).find("StoreName").text());
}
});
有哪个一切工作正常,并不会造成错误页面上的其他jQuery的代码加载,所以我不是很明白什么是错。该页面不是“活的”,因此不幸的是不能提供链接。
它列出的错误是
文件类型不允许元素 “IMG” 这里
和代码它指向的线是在这里:
statuscontent = "<img src='/web/resources/graphics/accept.png' alt='' /> System OK";
它下一个作业也有问题statuscontent
让你的JavaScript代码在外部。 – Gumbo 2011-02-02 15:36:02
@Gumbo同意,除非您的托管人以请求限制惩罚您。 – 2011-02-02 15:36:48