Ajax IE 7 and Vista

R

rbrowning1958

Hello,

I posted a thread a couple of days back RE using Ajax with JS to read
an XML file. This isn't working form me in IE 7 and Vista:

xmlhttp = new XMLHttpRequest();

xmlhttp.open("GET", url);

where url is a file on my local disk. This works in FireFox, and in
Safari but not IE. IE returns an "Access denied" error when trying to
access the file. This will not be a problem when it's deployed as it
will be reading a file from the server but this is messing up my
testing - anyone know how to configure IE security etc. to allow this?
I've tried usual things but all failing.

Ta

Ray
 
T

Thomas 'PointedEars' Lahn

rbrowning1958 said:
I posted a thread a couple of days back RE using Ajax with JS to read
an XML file.

If it was only a couple of days back then it would have been appropriate to
simply continue that thread you are referring to.
This isn't working form me in IE 7 and Vista:

xmlhttp = new XMLHttpRequest();

xmlhttp.open("GET", url);

where url is a file on my local disk. This works in FireFox, and in
Safari but not IE. IE returns an "Access denied" error when trying to
access the file.

Probably due to the MSXML's equivalent of the Same Origin Policy. As you do
not show the value of `url', let alone state the line in which the error
occurs, one can only make that educated guess.

http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork
This will not be a problem when it's deployed as it will be reading a
file from the server but this is messing up my testing -

Please be more specific about what you are doing.
anyone know how to configure IE security etc. to allow this?

I don't think that is possible. However, a local Web server for testing
would probably help here and it is a good idea anyway.
I've tried usual things but all failing.

That is a useless statement. What do you consider "the usual things"?


PointedEars
 
R

rbrowning1958

rbrowning1958wrote:

If it was only a couple of days back then it would have been appropriate to
simply continue that thread you are referring to.





Probably due to the MSXML's equivalent of the Same Origin Policy.  As you do
not show the value of `url', let alone state the line in which the error
occurs, one can only make that educated guess.

http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork


Please be more specific about what you are doing.


I don't think that is possible.  However, a local Web server for testing
would probably help here and it is a good idea anyway.


That is a useless statement.  What do you consider "the usual things"?

PointedEars
--
Prototype.js was written by people who don't knowjavascriptfor people
who don't knowjavascript. People who don't knowjavascriptare not
the best source of advice on designing systems that usejavascript.
  -- Richard Cornford, cljs, <[email protected]>

Hello PointedEars - cute name!

Thank you for taking the time to reply. I'll be more precise.
I didn't continue the original thread cos I fixed the errors I was
having there and narrowed it down to this simple stand alone problem.

I don't see how having the value of url or the line number will help
but seeing as you asked url is "xml/images.xml" and it's on line 28 in
my Javascript lol. It is an html file containing the javascript. It is
reading this XML file. I know it's failing on that line cos an alert
right after it never gets shown and IE reports the access deined error
if I tell it to report all errors in script. I am testing this
locally. When I get around to deploying it it will be on a Web server
which will have rights set up to allow access to the files on the
webserver. This for local testing.

By usual things I meant ensuring IE could run scripts, and that rights
for the folder were set to allow all access. I'll read up on same
origin policy - new to me. In fact all this is new to me. The I think
it's an IE security issue is cos it works fine in FireFox and Safari.
Just IE.

Thanks for taking the time to reply.
Ray
 
E

Ed

I don't see how having the value of url or the line number will help
but seeing as you asked url is "xml/images.xml" and it's on line 28 in
my Javascript lol. It is an html file containing the javascript. It is
reading this XML file. I know it's failing on that line cos an alert
right after it never gets shown and IE reports the access deined error
if I tell it to report all errors in script. I am testing this
locally. When I get around to deploying it it will be on a Web server
which will have rights set up to allow access to the files on the
webserver. This for local testing.

I think you are seeing the problem described here:

http://dev.jquery.com/ticket/963
 
T

Thomas 'PointedEars' Lahn

rbrowning1958 said:
I didn't continue the original thread cos I fixed the errors I was having
there and narrowed it down to this simple stand alone problem.

If there was no relationship to that thread at all, then referring to that
thread would not make sense either. You would not expect people to look it
up, now would you?
I don't see how having the value of url or the line number will help but
seeing as you asked url is "xml/images.xml" and it's on line 28 in my
Javascript lol. It is an html file containing the javascript. It is
reading this XML file. I know it's failing on that line cos an alert
right after it never gets shown and IE reports the access deined error if
I tell it to report all errors in script.

You should make improvements on the overall style of your postings if you
wish to be taken seriously in Usenet any further. This is _not_ chit-chat,
but a technical discussion which purpose is not only to analyze and solve
your problem (in the best possible way) but also to provide a learning
experience for other subscribers.

That includes, but is not limited to, *proper* quoting:

http://www.jibbering.com/faq/faq_notes/clj_posts.html
I am testing this locally. When I get around to deploying it it will be
on a Web server which will have rights set up to allow access to the
files on the webserver. This for local testing.

As I have said, you should set up a local test Web server so you can
reproduce the conditions on your remote production Web server. The file
system and HTTP are not equivalent, and if Ed's assumption is correct then
that would be exactly the cause of your problem.


PointedEars
 
R

rbrowning1958

rbrowning1958wrote:

If there was no relationship to that thread at all, then referring to that
thread would not make sense either.  You would not expect people to lookit
up, now would you?


You should make improvements on the overall style of your postings if you
wish to be taken seriously in Usenet any further.  This is _not_ chit-chat,
but a technical discussion which purpose is not only to analyze and solve
your problem (in the best possible way) but also to provide a learning
experience for other subscribers.

That includes, but is not limited to, *proper* quoting:

http://www.jibbering.com/faq/faq_notes/clj_posts.html


As I have said, you should set up a local test Web server so you can
reproduce the conditions on your remote production Web server.  The file
system and HTTP are not equivalent, and if Ed's assumption is correct then
that would be exactly the cause of your problem.

PointedEars
--
Prototype.js was written by people who don't knowjavascriptfor people
who don't knowjavascript. People who don't knowjavascriptare not
the best source of advice on designing systems that usejavascript.
  -- Richard Cornford, cljs, <[email protected]>

Hello Pointy ears,

In the interests of becoming a well behaved citizen - and having read
the FAQ you pointed me to I don't see the error of my ways. What
quoting did I do incorrectly? Do you think I was chit chatting?

Thanks for your time

Ray
 
R

rbrowning1958

I think you are seeing the problem described here:

 http://dev.jquery.com/ticket/963

Ed,

Spot on - thanks for that - it's allowed me to move forwards. I can
now read the file in both IE and FireFox - with IE using the Active X
(ActiveXObject("Microsoft.XMLHTTP")) and with FireFox using
XMLHttpRequest().

I've now run into some other compatibility between the two versions.
Both versions correctly read the XML file; I call my own routine from
the onreadystatechange event when state is 4:

req.onreadystatechange =
function() {
if (req.readyState == 4) {
preloadSlideshow(req);
}

So far so good and preloadSlideshow does indeed get called. Here's the
first part of it:

function preloadSlideshow(originalRequest) {
var slideshow = originalRequest.responseXML;
var slides = slideshow.getElementsByTagName('slide');
alert(slides.length.toString());
alert(originalRequest.responseText);

Both browsers display the responseText showing the entire XML file -
so they have both read it. The problem now is IE reports the number of
slide elements as 0, firefox correctly as 5. Is this another know bug?
Here's part of the XML file:

<slideshow>
<slide>
<image>images/slides/0013_arboretum_redbud.jpg</image>
<alttext>Photo: A very pretty picture</alttext>
<link>http://www.ucdavis.edu/about/</link>
<caption>A very pretty picture</caption>
<more>Scenes of UC Davis</more>
</slide>
<slide>
<image>images/slides/0016_aggie_band_trumpet.jpg</image>
<alttext>Photo: The Band-uh up close and personal</alttext>
<link>http://www.ucdavis.edu/sports_rec/</link>
<caption>The Band-uh up close and personal</caption>
<more>Scenes of UC Davis</more>
</slide>
...more here
</slideshow>

A bit frustrating all this!

Cheers

Ray
 
T

Thomas 'PointedEars' Lahn

rbrowning1958 said:
function preloadSlideshow(originalRequest) {
var slideshow = originalRequest.responseXML;
var slides = slideshow.getElementsByTagName('slide');
alert(slides.length.toString());
alert(originalRequest.responseText);

Both browsers display the responseText showing the entire XML file -
so they have both read it. The problem now is IE reports the number of
slide elements as 0, firefox correctly as 5. Is this another know bug?

Yes, it is. If you insist on using `file:' instead of `http:', you will
have to work around that with

var objXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
objXmlDoc.loadXML(originalRequest.responseText);
var slides = objXmlDoc.getElementsByTagName("slide");

Unsurprisingly, setting up a local Web server, as I already recommended
twice, will also avoid that workaround.


PointedEars
 
T

Thomas 'PointedEars' Lahn

rbrowning1958 said:
var slides = slideshow.getElementsByTagName('slide');
alert(slides.length.toString());

window.alert() (which should be called so) implicitly converts its argument
to string. Additional calling toString() is unnecessary, especially for a
number value.


PointedEars
 
R

rbrowning1958

rbrowning1958wrote:


Yes, it is.  If you insist on using `file:' instead of `http:', you will
have to work around that with

  var objXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  objXmlDoc.loadXML(originalRequest.responseText);
  var slides = objXmlDoc.getElementsByTagName("slide");

Unsurprisingly, setting up a local Web server, as I already recommended
twice, will also avoid that workaround.

PointedEars
--
Prototype.js was written by people who don't knowjavascriptfor people
who don't knowjavascript. People who don't knowjavascriptare not
the best source of advice on designing systems that usejavascript.
  -- Richard Cornford, cljs, <[email protected]>

Thanks for that. I'm not understanding what the code is doing if i'm
not specifiying File: or http: as part of the url. My code just calls
the get with a string for the file name, such as "xml/test.xml". If I
just run this HTML by opening it in IE (or actually from within
Dreamweaver as I'm doing) I suppose it is using file:. If I put this
within a virtual folder within IIS and then reference it using
localhost or whatever it is is this going to use http:? I'm think I'm
missing the difference here. Regardless it's still a shame that this
doesn't work the same way.

Thanks again for taking the tiem to reply - and I ack your other reply
RE toString(). I can't see it making any difference really except it
saves me typing it - I assume alert just calls toString() for all not
character data.

Cheers

Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top