Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14661 > unrolled thread
| Started by | Gene Wirchenko <genew@ocis.net> |
|---|---|
| First post | 2012-06-25 17:46 -0700 |
| Last post | 2012-06-26 22:34 +0100 |
| Articles | 11 — 6 participants |
Back to article view | Back to comp.lang.javascript
Unclear Error Code Gene Wirchenko <genew@ocis.net> - 2012-06-25 17:46 -0700
Re: Unclear Error Code Jeff North <jnorthau@yahoo.com.au> - 2012-06-26 11:32 +1000
Re: Unclear Error Code Gene Wirchenko <genew@ocis.net> - 2012-06-25 21:03 -0700
Re: Unclear Error Code Mike Winter <usenet@michael-winter.me.invalid> - 2012-06-26 20:55 +0100
Re: Unclear Error Code Gene Wirchenko <genew@ocis.net> - 2012-06-26 13:30 -0700
Re: Unclear Error Code Stefan Weiss <krewecherl@gmail.com> - 2012-06-26 22:54 +0200
Re: Unclear Error Code Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-26 23:20 +0200
Re: Unclear Error Code Gene Wirchenko <genew@ocis.net> - 2012-06-26 16:42 -0700
Re: Unclear Error Code Stefan Weiss <krewecherl@gmail.com> - 2012-06-27 02:29 +0200
Re: Unclear Error Code Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2012-06-26 23:18 +0200
Re: Unclear Error Code Mike Winter <usenet@michael-winter.me.invalid> - 2012-06-26 22:34 +0100
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-25 17:46 -0700 |
| Subject | Unclear Error Code |
| Message-ID | <8a1iu79jj1som7u942t6f4sbbmhjov3kq8@4ax.com> |
Dear JavaScripters:
Basic Ajax experimenting. My simple code -- go to a site, grab a
page, and display it -- works just fine with IE 9, but with Firefox,
my XMLHttpRequest.open() call throws
Component returned failure code: 0x805e0006 [nslXMLHttpRequest.open]
This is not as clear as it could be.
What does it mean, what can I do about it, and why the difference
between IE and FF on such simple code?
Sincerely,
Gene Wirchenko
[toc] | [next] | [standalone]
| From | Jeff North <jnorthau@yahoo.com.au> |
|---|---|
| Date | 2012-06-26 11:32 +1000 |
| Message-ID | <194iu7p9b6t4ef3aupclci13u012frunpg@4ax.com> |
| In reply to | #14661 |
On Mon, 25 Jun 2012 17:46:30 -0700, in comp.lang.javascript Gene Wirchenko <genew@ocis.net> <8a1iu79jj1som7u942t6f4sbbmhjov3kq8@4ax.com> wrote: >| Dear JavaScripters: >| >| Basic Ajax experimenting. My simple code -- go to a site, grab a >| page, and display it -- works just fine with IE 9, but with Firefox, >| my XMLHttpRequest.open() call throws >| >| Component returned failure code: 0x805e0006 [nslXMLHttpRequest.open] >| >| This is not as clear as it could be. >| >| What does it mean, what can I do about it, and why the difference >| between IE and FF on such simple code? >| >| Sincerely, >| >| Gene Wirchenko The first google hit returned a solution to this problem: http://support.mozilla.org/en-US/questions/917806
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-25 21:03 -0700 |
| Message-ID | <p4diu75iefnrcbm62bm46oglu9mf7ql7og@4ax.com> |
| In reply to | #14662 |
On Tue, 26 Jun 2012 11:32:45 +1000, Jeff North <jnorthau@yahoo.com.au>
wrote:
>On Mon, 25 Jun 2012 17:46:30 -0700, in comp.lang.javascript Gene
>Wirchenko <genew@ocis.net>
><8a1iu79jj1som7u942t6f4sbbmhjov3kq8@4ax.com> wrote:
>
>>| Dear JavaScripters:
>>|
>>| Basic Ajax experimenting. My simple code -- go to a site, grab a
>>| page, and display it -- works just fine with IE 9, but with Firefox,
>>| my XMLHttpRequest.open() call throws
>>|
>>| Component returned failure code: 0x805e0006 [nslXMLHttpRequest.open]
>>|
>>| This is not as clear as it could be.
>>|
>>| What does it mean, what can I do about it, and why the difference
>>| between IE and FF on such simple code?
>>|
>>| Sincerely,
>>|
>>| Gene Wirchenko
>
>The first google hit returned a solution to this problem:
>http://support.mozilla.org/en-US/questions/917806
But I do not use AdBlock.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Mike Winter <usenet@michael-winter.me.invalid> |
|---|---|
| Date | 2012-06-26 20:55 +0100 |
| Message-ID | <dtoGr.405303$jl.276261@fx19.am4> |
| In reply to | #14664 |
On 26/06/2012 05:03, Gene Wirchenko wrote: > On Tue, 26 Jun 2012 11:32:45 +1000, Jeff North <jnorthau@yahoo.com.au> > wrote: > >> On Mon, 25 Jun 2012 17:46:30 -0700, Gene Wirchenko <genew@ocis.net> >> wrote: >> >>> Basic Ajax experimenting. My simple code -- go to a site, grab a >>> page, and display it -- works just fine with IE 9, but with Firefox, >>> my XMLHttpRequest.open() call throws [an exception.] >>> >>> [snip] >> >> The first google hit returned a solution to this problem: >> http://support.mozilla.org/en-US/questions/917806 > > But I do not use AdBlock. Hi Gene, Could this be a cross-site issue? Without knowing the details of what you're doing (preferably in the form of a public "working" demo), it's difficult to tell. <https://developer.mozilla.org/en/DOM/XMLHttpRequest/Using_XMLHttpRequest#Cross-site_XMLHttpRequest> <https://developer.mozilla.org/En/HTTP_access_control> Kind regards, Mike -- Michael Winter Replace ".invalid" with ".uk" to reply by e-mail.
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-26 13:30 -0700 |
| Message-ID | <326ku7dmhf5i0hosp63996crif8apmlm9f@4ax.com> |
| In reply to | #14682 |
On Tue, 26 Jun 2012 20:55:56 +0100, Mike Winter
<usenet@michael-winter.me.invalid> wrote:
>On 26/06/2012 05:03, Gene Wirchenko wrote:
>
>> On Tue, 26 Jun 2012 11:32:45 +1000, Jeff North <jnorthau@yahoo.com.au>
>> wrote:
>>
>>> On Mon, 25 Jun 2012 17:46:30 -0700, Gene Wirchenko <genew@ocis.net>
>>> wrote:
>>>
>>>> Basic Ajax experimenting. My simple code -- go to a site, grab a
>>>> page, and display it -- works just fine with IE 9, but with Firefox,
>>>> my XMLHttpRequest.open() call throws [an exception.]
>>>>
>>>> [snip]
>>>
>>> The first google hit returned a solution to this problem:
>>> http://support.mozilla.org/en-US/questions/917806
>>
>> But I do not use AdBlock.
>Could this be a cross-site issue? Without knowing the details of what
Since I am just starting with this, how would I know? (I really
like informative error messages. I am not seeing them here.)
>you're doing (preferably in the form of a public "working" demo), it's
>difficult to tell.
It really is a simple bit of code. Mouseover one of the images
to get some text about it. Mouseout to erase the text display.
This code works fine with IE 9 for most sites (more on this
later), and throws the error I note above for everything that I have
tried.
For some reason, Deitel's test site does return the .jpg files,
but throws a 404 for the text saying that the server is down. (Say
what?) For my limited use, I am fine with that. I *can* pick up the
text. I substituted the URL of the company that I work for for the
leftmost link, and its page does get picked up. (I do not know why I
do not get the HTML, but that is something for later. Or maybe, you
know.)
Some sites do not work this way, and I see another error (and
this in IE) which is secondary, but might help you figure where I am
going wrong. One such site is
http://www.dilbert.com/
Then, I get a an error of
Error: Could not complete the operation due to error
c00ce56e.
in the line that displays the returned text.
I have already had to massage this code somewhat to get it
working as much as it is. I do not think that I have introduced any
errors, but what do I know? I admit that it is not much in this area,
yet. (I have left the logic alone as much as possible. In
particular, I have left GetContent()'s try block alone.)
***** Start of Code *****
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>2012-06-22: 15.5 "Raw" Ajax Example Using the XMLHttpRequest
Object</title>
<style type="text/css">
.Box
{
border: 1px solid black;
padding: 10px;
}
</style>
<script type="text/javascript">
var AsyncRequest; // XHLHttpRequest object
// Set up and send the asynchronous request.
function GetContent
(
Url
)
{
// Attempt to create the XMLHttpRequest and make the request.
try
{
AsyncRequest=new XMLHttpRequest();
// Register event handler.
AsyncRequest.onreadystatechange=StateChange;
AsyncRequest.open("GET",Url,true); // Prepare request.
AsyncRequest.send(null); // Send request.
}
catch (e)
{
document.getElementById("HttpStatus").innerHTML=
"Request failed.\n"+
e.name+"\n"+
e.message+"\n";
}
}
// Display the response data on the page.
function StateChange()
{
if (AsyncRequest.readyState==4)
{
var HttpStatus=AsyncRequest.status;
var HttpStatusType=HttpStatus/100;
if (HttpStatusType==1) // Ignore 1xx
return;
else
{
document.getElementById("HttpStatus").innerHTML=
"Request status: "+AsyncRequest.status;
document.getElementById("ContentArea").innerHTML=
AsyncRequest.responseText; // puts text in content area
}
}
}
// Clear content area.
function ClearContent()
{
document.getElementById("HttpStatus").innerHTML=""; // Clear
status message.
document.getElementById("ContentArea").innerHTML="";
}
// Strip ending (. and after).
function BaseName
(
Url
)
{
var xUrl=Url.lastIndexOf(".");
if (xUrl==-1)
return Url;
return Url.substr(0,xUrl);
}
</script>
</head>
<body>
<h1>Mouse over a book for more information.</h1>
<img
src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/cpphtp6.jpg"
onmouseover='GetContent("http://www.ucantrade.com/"); //*****
onmouseover changed'
onmouseout="ClearContent();">
<img
src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/iw3htp4.jpg"
onmouseover='GetContent(BaseName(this.src)+".html");'
onmouseout="ClearContent();">
<img
src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/jhtp7.jpg"
onmouseover='GetContent(BaseName(this.src)+".html");'
onmouseout="ClearContent();">
<img
src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/vbhtp3.jpg"
onmouseover='GetContent(BaseName(this.src)+".html");'
onmouseout="ClearContent();">
<img
src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/vcsharphtp2.jpg"
onmouseover='GetContent(BaseName(this.src)+".html");'
onmouseout="ClearContent();">
<img
src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/chtp5.jpg"
onmouseover='GetContent(BaseName(this.src)+".html");'
onmouseout="ClearContent();">
<div id=HttpStatus class=Box> </div>
<div id=ContentArea class=Box> </div>
</body>
</html>
***** End of Code *****
[snip]
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2012-06-26 22:54 +0200 |
| Message-ID | <jsd7hr$tqm$1@news.albasani.net> |
| In reply to | #14685 |
On 2012-06-26 22:30, Gene Wirchenko wrote:
> <img
> src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/cpphtp6.jpg"
> onmouseover='GetContent("http://www.ucantrade.com/"); //*****
Looks like Mike is right, and you're running into a SOP-problem. If
you're not loading the page from www.ucantrade.com, you can't send an
XHR to that server:
https://en.wikipedia.org/wiki/Same_origin_policy
- stefan
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-06-26 23:20 +0200 |
| Message-ID | <1548037.q8OKcOxoW2@PointedEars.de> |
| In reply to | #14688 |
Stefan Weiss wrote:
> On 2012-06-26 22:30, Gene Wirchenko wrote:
>> <img
>> src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/cpphtp6.jpg"
>> onmouseover='GetContent("http://www.ucantrade.com/"); //*****
>
> Looks like Mike is right, and you're running into a SOP-problem. If
> you're not loading the page from www.ucantrade.com, you can't send an
> XHR to that server:
> https://en.wikipedia.org/wiki/Same_origin_policy
This article is lacking several references (and is marked so), and is
outdated at best. Unfortunately, it is generally a good idea to avoid
Wikipedia articles on the topic of this newsgroup, or take them with a
*handful* of salt.
For more up-to-date information, see e. g.:
<https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript>
<https://developer.mozilla.org/En/HTTP_access_control>
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-26 16:42 -0700 |
| Message-ID | <d5iku71950s43qlb6hvcosc3s5c9qkiedb@4ax.com> |
| In reply to | #14688 |
On Tue, 26 Jun 2012 22:54:18 +0200, Stefan Weiss
<krewecherl@gmail.com> wrote:
>On 2012-06-26 22:30, Gene Wirchenko wrote:
>> <img
>> src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/cpphtp6.jpg"
>> onmouseover='GetContent("http://www.ucantrade.com/"); //*****
>
>Looks like Mike is right, and you're running into a SOP-problem. If
^^^
Please expand this.
>you're not loading the page from www.ucantrade.com, you can't send an
>XHR to that server:
>https://en.wikipedia.org/wiki/Same_origin_policy
In IE 9, I have no problem at all. In Firefox 13.0.1, it blows
up every time.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2012-06-27 02:29 +0200 |
| Message-ID | <jsdk59$44t$1@news.albasani.net> |
| In reply to | #14699 |
On 2012-06-27 01:42, Gene Wirchenko wrote: > On Tue, 26 Jun 2012 22:54:18 +0200, Stefan Weiss > <krewecherl@gmail.com> wrote: >> Looks like Mike is right, and you're running into a SOP-problem. If > ^^^ > Please expand this. Same Origin Policy (see below). >> you're not loading the page from www.ucantrade.com, you can't send an >> XHR to that server: >> https://en.wikipedia.org/wiki/Same_origin_policy That article gives a usable (I think) overview of the general problem. It may be a little outdated, and missing references, as PE pointed out, but gives a decent introduction. For more details, check out the other references in PE's reply. > In IE 9, I have no problem at all. In Firefox 13.0.1, it blows > up every time. It "blows up" in every browser I've installed here. IE9 is not available on my platform, but I doubt this policy would have changed dramatically since IE8. The (embarrassingly out of date and insecure) version of IE8 that I've got running in a VM gives the expected error: "Request failed. TypeError Access denied". It's possible to tell IE to trust certain hosts, so that the SOP restrictions may be relaxed in your case. Try uploading the same page to an untrusted webserver and try again. Or try this one: http://foo.at/tmp/2012/soptest.html I have little experience with IE, but I guess it may be possible to deactivate some security features completely. If you did that, you may want to reset them to their defaults (for your own safety). Anyway, it "shouldn't work". If you want to access data from a different host, you'll need to use one of the workarounds mentioned in the linked pages (like JSONP). If all else fails, you can have your webserver fetch the remote data and proxy it for your client. - stefan
[toc] | [prev] | [next] | [standalone]
| From | Bjoern Hoehrmann <bjoern@hoehrmann.de> |
|---|---|
| Date | 2012-06-26 23:18 +0200 |
| Message-ID | <kl9ku75amknlgt0jtcaph741am6sakci5l@hive.bjoern.hoehrmann.de> |
| In reply to | #14685 |
* Gene Wirchenko wrote in comp.lang.javascript: > Some sites do not work this way, and I see another error (and >this in IE) which is secondary, but might help you figure where I am >going wrong. One such site is > http://www.dilbert.com/ >Then, I get a an error of > Error: Could not complete the operation due to error >c00ce56e. >in the line that displays the returned text. % http-head http://www.dilbert.com/ HTTP/1.1 200 OK Date: Tue, 26 Jun 2012 21:17:32 GMT Server: Apache/2.2.3 (CentOS) X-Powered-By: PHP/5.2.10 ... Content-Type: text/html; charset=utf-8lias The error code indicates that MSXML does not recognize the encoding `utf-8lias`. -- Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de 25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
[toc] | [prev] | [next] | [standalone]
| From | Mike Winter <usenet@michael-winter.me.invalid> |
|---|---|
| Date | 2012-06-26 22:34 +0100 |
| Message-ID | <nVpGr.341316$B64.261260@fx26.am4> |
| In reply to | #14685 |
On 26/06/2012 21:30, Gene Wirchenko wrote:
> On Tue, 26 Jun 2012 20:55:56 +0100, Mike Winter
> <usenet@michael-winter.me.invalid> wrote:
>
>> [snip]
>>
>> Could this be a cross-site issue? Without knowing the details of what
>
> Since I am just starting with this, how would I know? (I really
> like informative error messages. I am not seeing them here.)
Trying to fetch and manipulate data from a remote server is potentially
hazardous: it's assumed that the developer doesn't have control of that
remote data. To address this constraints are placed on what scripts can
access, and this affects various things including the contents of iframe
elements and XMLHttpRequest objects. You can read more about the
background of this by Googling:
"cross site | domain" | XSS
and "same origin policy". It is possible to explicitly signal that
accessing data like this is expected by sending a particular HTTP header
as part of the remote response (see "HTTP access control" linked in my
previous post).
>> you're doing (preferably in the form of a public "working" demo), it's
>> difficult to tell.
>
> It really is a simple bit of code. Mouseover one of the images
> to get some text about it. Mouseout to erase the text display.
The intent is simple, I'm sure, but the practicalities aren't
necessarily so.
> This code works fine with IE 9 for most sites (more on this
> later), and throws the error I note above for everything that I have
> tried.
This may simply be down to how that browser is configured: XSS security
restrictions can be disabled.
> For some reason, Deitel's test site does return the .jpg files,
> but throws a 404 for the text saying that the server is down. (Say
> what?) For my limited use, I am fine with that. I *can* pick up the
> text. I substituted the URL of the company that I work for for the
> leftmost link, and its page does get picked up. (I do not know why I
> do not get the HTML, but that is something for later. Or maybe, you
> know.)
I'm afraid I don't know what you're referring to, here. This is why
links to publically-hosted demonstrations are so valuable.
> [snip]
> <img
> src="http://test.deitel.com/examples/iw3htp4/ajax/thumbs/cpphtp6.jpg"
> onmouseover='GetContent("http://www.ucantrade.com/"); //*****
> onmouseover changed'
> onmouseout="ClearContent();">
> [snip]
As Stefan observed, the fact that you're dealing with two very different
domains here (and probably running your test from a third!) suggests
that you're going to run into XSS issues. Indeed, when I look at
<http://www.michael-winter.me.uk/test.html> in Chrome with the error
console open, each event triggers an error precisely because of this.
The links you've already been provided in this thread give a thorough
discussion of the issues and how "HTTP access control" can be used to
circumvent it.
Kind regards,
Mike
Note: My demo link above will be temporary but, for now, replicates the
code Gene posted in <news:326ku7dmhf5i0hosp63996crif8apmlm9f@4ax.com>
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web