我有一些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