Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

XMLHttpRequest for "HEAD" dumps "no element found" errors

瀏覽次數:5 次
跳到第一則未讀訊息

Michael Vincent van Rantwijk

未讀,
2005年9月4日 凌晨3:59:592005/9/4
收件者:
I use somehing like this:

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("HEAD", aURL, false);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
return xmlhttp.getResponseHeader("Last-Modified");
}
}
xmlhttp.send(null);

and that works, but it throws JavaScript errors like this:

Error: [JavaScript Error: "no element found" {file:
"http://mozillazine.org/atom.xml" line: 1 column: 1 source: "
^"}]
Source File: http://mozillazine.org/atom.xml
Line: 1, Column: 1
Source Code:
^

Why is that?
Note that I looked for "no element found" and found this:

http://lxr.mozilla.org/seamonkey/search?string=no%20element%20found

but only the headers are send, not the file, so why does it spit out
this kind of XML parser errors?

Michael

Michael Vincent van Rantwijk

未讀,
2005年9月4日 凌晨4:12:162005/9/4
收件者:
Michael Vincent van Rantwijk wrote:
> I use somehing like this:
>
> var xmlhttp = new XMLHttpRequest();
> xmlhttp.open("HEAD", aURL, false);

Err, make that xmlhttp.open("HEAD", aURL, true);

Martin Honnen

未讀,
2005年9月4日 上午9:22:272005/9/4
收件者:

Michael Vincent van Rantwijk wrote:

> I use somehing like this:
>
> var xmlhttp = new XMLHttpRequest();
> xmlhttp.open("HEAD", aURL, false);
> xmlhttp.onreadystatechange = function() {
> if (xmlhttp.readyState == 4) {
> return xmlhttp.getResponseHeader("Last-Modified");
> }
> }
> xmlhttp.send(null);
>
> and that works, but it throws JavaScript errors like this:
>
> Error: [JavaScript Error: "no element found" {file:
> "http://mozillazine.org/atom.xml" line: 1 column: 1 source: "
> ^"}]
> Source File: http://mozillazine.org/atom.xml
> Line: 1, Column: 1
> Source Code:
> ^

I have tried with Mozilla 1.7.11 and no errors happen, but when I try
with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4)
Gecko/20050806 Firefox/1.0+ I see the error so it looks like a
regression that happened on the trunk after 1.7. Although I don't know
whether something has changed with XMLHttpRequest and HEAD requests or
maybe only error reporting, lots of stuff nowadays ends up in the
JavaScript console although it is not a script error.

Consider filing a bug on the issue and please post the bug number here.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Michael Vincent van Rantwijk

未讀,
2005年9月4日 中午12:58:202005/9/4
收件者:
Martin Honnen wrote:
>
>
> Michael Vincent van Rantwijk wrote:
>
>> I use somehing like this:
>>
>> var xmlhttp = new XMLHttpRequest();
>> xmlhttp.open("HEAD", aURL, false);
>> xmlhttp.onreadystatechange = function() {
>> if (xmlhttp.readyState == 4) {
>> return xmlhttp.getResponseHeader("Last-Modified");
>> }
>> }
>> xmlhttp.send(null);
>>
>> and that works, but it throws JavaScript errors like this:
>>
>> Error: [JavaScript Error: "no element found" {file:
>> "http://mozillazine.org/atom.xml" line: 1 column: 1 source: "
>> ^"}]
>> Source File: http://mozillazine.org/atom.xml
>> Line: 1, Column: 1
>> Source Code:
>> ^
>
> I have tried with Mozilla 1.7.11 and no errors happen, but when I try
> with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4)
> Gecko/20050806 Firefox/1.0+ I see the error so it looks like a
> regression that happened on the trunk after 1.7. Although I don't know
> whether something has changed with XMLHttpRequest and HEAD requests or
> maybe only error reporting, lots of stuff nowadays ends up in the
> JavaScript console although it is not a script error.

FYI: I don't get the error for HTML files, so maybe this is limited to
XML files?

> Consider filing a bug on the issue and please post the bug number here.

I hope someone else can do that, because I don't know what component to
use, and that's just one of the things I should know--but I don't.

Thanks,
Michael

Martin Honnen

未讀,
2005年9月4日 下午2:32:192005/9/4
收件者:

Michael Vincent van Rantwijk wrote:

> Martin Honnen wrote:
>
>> Consider filing a bug on the issue and please post the bug number here.
>
> I hope someone else can do that, because I don't know what component to
> use, and that's just one of the things I should know--but I don't.

Bug report is <https://bugzilla.mozilla.org/show_bug.cgi?id=307049>.

Michael Vincent van Rantwijk

未讀,
2005年9月4日 下午3:21:222005/9/4
收件者:
Martin Honnen wrote:
>
>
> Michael Vincent van Rantwijk wrote:
>> Martin Honnen wrote:
>>
>>> Consider filing a bug on the issue and please post the bug number here.
>>
>> I hope someone else can do that, because I don't know what component
>> to use, and that's just one of the things I should know--but I don't.
>
> Bug report is <https://bugzilla.mozilla.org/show_bug.cgi?id=307049>.

Wow, Peter van der Beken already has a patch for it, perfect!

Danke Martin ;)

Michael

0 則新訊息