當我使用Chroms的JavaScript工具查看時,我在此頁面上看到一些JavaScript錯誤消息。我無法理解它們爲何發生。這裏是頁面:Javascript錯誤消息難以理解
http://www.comehike.com/outdoors/parks/trailhead.php
任何想法是什麼問題呢?
當我使用Chroms的JavaScript工具查看時,我在此頁面上看到一些JavaScript錯誤消息。我無法理解它們爲何發生。這裏是頁面:Javascript錯誤消息難以理解
http://www.comehike.com/outdoors/parks/trailhead.php
任何想法是什麼問題呢?
谷歌控制檯:
Uncaught TypeError: Cannot read property 'documentElement' of null trailhead.php:84
trailhead.php:
request.onreadystatechange = function()
{
if (request.readyState == 4)
{
var xmlDoc = request.responseXML;
...
// obtain the array of markers and loop through it
markers = xmlDoc.documentElement.getElementsByTagName("marker");
xmlDoc中爲空,這意味着該請求或者不接受任何東西,或沒有收到有效的XML。而且事實證明是後者:
This page contains the following errors:
error on line 21 at column 2381: attributes construct error
Below is a rendering of the page up to the first error.
在任何情況下,屬性施工誤差是因爲你已經(在這裏格式的可讀性):
<marker trailhead_name="Parrish Creek Trail"
trailhead_description="From Interstate 15 take Centerville exit 319.
Go east on Parrish Lane. At 700 East turn left
at the "T." Follow the narrow road to the
trailhead." />
你有以"T."
作爲"T."
逃脫。
老實說,這些錯誤信息並不難理解。如果有的話,他們非常有幫助。
我看到的一個問題是AJAX請求收到無效的XML。有沒有轉換爲HTML實體的引號。
XML Parsing Error: not well-formed Location: moz-nullprincipal:{ae7bee0f-3857-5344-ac34-31cd2a941e51} Line Number 21, Column 5841:
...t on Parrish Lane. At 700 East turn left at the "T." Follow the narrow road t...
...-------------------------------------------------^
你需要確保你的Ajax調用狀態OK您嘗試訪問數據
if (request.readyState == 4 && request.status == 200)
而且你的XML響應不能很好地形成
http://www.comehike.com/outdoors/parks/trailhead_ajax.php 給出了一個錯誤之前。
請在這裏發佈錯誤消息,並解釋你在做什麼,什麼是不工作。不要只指望別人爲你做所有的工作 – Thomas 2011-06-05 06:01:45
你在你的ajax中有錯誤,發佈它並且會得到幫助 – Ibu 2011-06-05 06:03:14
@Thomas控制檯中的錯誤非常糟糕,並且有一些diff消息。我在JS很新手...會嘗試發佈相關錯誤。 – Genadinik 2011-06-05 06:05:12