From: David Mark on
VK wrote:
> On Apr 23, 12:20 am, VK <schools_r...(a)yahoo.com> wrote:
>> On Apr 23, 12:18 am, VK <schools_r...(a)yahoo.com> wrote:
>>
>>> r = setRequestHeader('Content-Type', 'text/xml'); // <-
>> damn... I mean:
>>
>> r.setRequestHeader('Content-Type', 'text/xml');
>
> double damn... Sorry, did not work with XHR object directly for year.
> Forget the above, try:
>
> r.overrideMimeType('text/xml')
>

Triple damn. That won't work in IE unless you use the ActiveX XHR
variety (and the user allows ActiveX to run). Your scatter-shot method
of problem solving isn't working.

Some things never change.
From: Garrett Smith on
David Mark wrote:
> VK wrote:
>> On Apr 23, 12:20 am, VK <schools_r...(a)yahoo.com> wrote:
>>> On Apr 23, 12:18 am, VK <schools_r...(a)yahoo.com> wrote:
>>>

[...]

>>
>> r.overrideMimeType('text/xml')
>>

Not implemented in IE.

>
> Triple damn. That won't work in IE unless you use the ActiveX XHR
> variety (and the user allows ActiveX to run). Your scatter-shot method
> of problem solving isn't working.
>

Is yours?

var a = new ActiveXObject("Microsoft.XMLHTTP");
alert(typeof a.overrideMimeType);

"undefined"

If the discussion is about loading a local file off the filesystem (and
it is), then that isn't going to work very well using XMLHttpRequest, is it?

[1]http://www.w3.org/TR/XMLHttpRequest/#introduction
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Garrett Smith on
foka wrote:
> Hi.I have got a problem with javascript and XML.
> I want to put data from XML file to HTML <select> options.
> My code is working but only if I put this (websites) on server, but I
> want to run my html site on every comp, localy, for example from CD., on
> windows without Apache etc.
> When I run my site localy file:///C:/file.html then my <select> is empty.
>
> My Ajax code:

As you have noticed, some browsers support file protocol with
XMLHttpRequest and IE doesn't. The ActiveXObject constructor does
support that.

You're attemtping to use XMLHttpRequest for something it was not
designed for. XMLHttpRequest is in Working Draft status, and is
specified therein for http and https only[1].

You might want to try XMLDocument[2], however that is going to depend on
the security settings of IE. Perhaps someone can provide the fine
details of that, as well as indicate the proper progids to try.

Example:

<script type="text/javascript">
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.async = false;
xmlDoc.load("items.xml");
if(xmlDoc.parseError.errorCode != 0) {
alert("Error" + xmlDoc.parseError.errorCode);
} else {
document.write("Your XML File, items.xml:<xmp>", xmlDoc.xml);
}
</script>

[1]<http://www.w3.org/TR/XMLHttpRequest/#introduction>
[2]<http://msdn.microsoft.com/en-us/library/ms757828(v=VS.85).aspx>
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: VK on
On Apr 23, 10:47 am, David Mark <dmark.cins...(a)gmail.com> wrote:
> Your scatter-shot method
> of problem solving isn't working.

Baby, this is why I said at first to OP "I would just take a time
verified AJAX library rather that reinventing the wheel and hitting
all per browser and per situation bizarrities." I didn't work with
XMLHttpRequest directly for years by now and no one serious did. Can
you recall when the last time you directly programmed CGI input
handling REQUEST_METHOD, QUERY_STRING, CONTENT_LENGTH etc? Or manually
forming TCP/IP packets for HTTP requests? Surely it is still on tips
of your fingers, right?

0 instead of 200 for status and empty responseXML for local files
reading is a long standing XHR silliness and any more or less descent
lib handles it over particular wrappers. Long time I was promoting
AjaxRequest by Matt Kruse http://www.ajaxtoolbox.com/request/ but the
project is abandoned for years and the last version never fixed the "0
instead 200" workaround I reported back in 2005 at least, so for local
files responseText needs to be read from onError listener rather than
from onSuccess. That kind of prevent from promoting it in this case.

So any AjaxRequest-like library? Yes, to be universal it has to use
responseText only for local files and then serialize it back to XML if
XML is needed. I am just bored to post 1001st explanation of something
being done in so many libraries.


From: Garrett Smith on
Thomas 'PointedEars' Lahn wrote:
> Garrett Smith wrote:
>
>> foka wrote:
>>> Hi.I have got a problem with javascript and XML.
>>> I want to put data from XML file to HTML <select> options.
>>> My code is working but only if I put this (websites) on server, but I
>>> want to run my html site on every comp, localy, for example from CD., on
>>> windows without Apache etc.
>>> When I run my site localy file:///C:/file.html then my <select> is empty.
>>>
>>> My Ajax code:
>> As you have noticed, some browsers support file protocol with
>> XMLHttpRequest and IE doesn't. The ActiveXObject constructor does
>> support that.
>
> Correct.
>
>> You're attemtping to use XMLHttpRequest for something it was not
>> designed for. XMLHttpRequest is in Working Draft status, and is
>> specified therein for http and https only[1].
>
> Utter nonsense. When will you ever learn? The fact that a *draft*
> specifies something has absolutely no intrinsic meaning at all. Which is
> emphasized by the mere fact that XMLHttpRequest works for non-http and non-
> https URLs outside of MSHTML, i.e. in the majority of implementations, where
> some of them support considerable portions of the draft.
>

The fact that I wrote that: "XMLHttpRequest is in Working Draft status"
indicates that it is a *draft*. You called that "utter nonsense", then
stated that it is a draft and asked me when I will ever learn. Well I
already knew that when I wrote it. It sounds like you are being
ridiculous and and self contradictory.

Should XMLHttpRequest use "file:///" or "file://" or "[drive]:\"? Or is
it limited to relative paths? If so, what is the file separator? Is the
browser expected to map "/" to the separator for that OS? Or should the
code not expect that "/" gets mapped to "\" or ":" (or (hopefully
not)"." or ">")? What about navigating to parent directories?

File protocol for browser-based applications is not specified. Maybe one
day it will be but for now it is not. Nor is behavior of file protocol
well-documented.

A good first place to start for determining recommendation for file
protocol would be to write a test suite and run existing implementations
through it to see how they behave.

> MSHTML 8 in IE 8 supports but one feature of HTML 5 as specified in the
> draft, and it is not XMLHttpRequest.¹ It is illogical to conclude that
> XMLHttpRequest works so in MSHTML because it *might* become so in HTML 5.
>
> ¹ <http://blogs.msdn.com/giorgio/archive/2009/11/29/ie8-and-html-5.aspx>
>
Is there a point in linking to that blog?

[...]

>> Example:
>>
>> <script type="text/javascript">
>> var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
>
> var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
>
>> xmlDoc.async = false;
>> xmlDoc.load("items.xml");
>
> xmlDoc.loadXML(xhr.responseText);

That would require creating two ActiveX objects; one for the request and
one for the parsing of the xhr responseText into a document.

Whereas if load is used, only one ActiveX object is needed.
[...]
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9
Prev: Quicktime and innerHTML
Next: option & textnode