Geeks With Blogs

Tim Huffam Dotting the I and crossing the T of I.T.

As yet I don't have the answer to this problem - so any suggestions would be very much appreciated!

I have a JS library with an object that loads xml from a specified URL and populates specified HTML elements with the data.  This works fine.

However recently I refactored the code that calls this library, to be more OO (to allow it to be more easily extended).  Now the xml "load()" method raises the error "Access is denied" when loading from external urls.

I've proved that the load library still works ok by calling it from a simple test script. 

So why does the behavior of a JS function change based on what has called it?

Any help will be very much appreciated!
Thanks in advance
Tim

Posted on Wednesday, May 17, 2006 8:13 AM ASP.NET , Web Development, JavaScript & CSS | Back to top


Comments on this post: Access is denied - Javascript error when attempting to load xml from an external site.

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Hi,
You can not access the xml,if located in another domain.you can create an intermediate page,which in turn gets the xml and sends it back to u using Ajax. you can see my site "http://aspspider.net/jayaveer/", here i am fetching my rss and displaying in a table format.(click on blog icon).Hope this will help u. :)
Left by Jayaveer on May 17, 2006 11:29 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Thanks Jayaveer

Yes I agree - but it doesnt explain why it sometimes works.

Eg it works fine in my test JS on a web page hosted on my local web server where the JS accesses xml (ajax) from an external site.

I was hoping I could avoid the overhead on my server - but making the client go directly to the external data source (which up till now has worked fine).

Many thanks
Tim
Left by Tim on May 17, 2006 12:10 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
an extract - that I read <ahref="http://www.dannyg.com/ref/jsminifaq.html"> here <a/> once and went "ahhaa" when I read it :) (though this really may not pertain to your example - might be worth looking at the link)

"One more source of this error in IE occurs if you assign a too-long search string to a URL or a form (using the GET method) has lots of elements and data. The HTTP GET method has a built-in limit of approximately 512 characters. If you run into the problem, change the method to POST, which has no data length limit. But POST won't reflect the search string in the URL of the replacement page (in case you're expecting to parse that data as a way to convey data from one page to the next). "

Also, I know this is stupid but the second server which hosts the XML has the permissions set correctly? So, assuming the second server if foo.com and file is foo.xml you can see the xml when you browse foo.com/foo.xml?

From what i understand you're trying to access a XML which is hosted in a completely different domain - it works fine using a script but doesn't work fine using IE?
if that's the case the above link might explain it.
Left by rajiv popat on May 17, 2006 2:38 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Thanks Rajiv

Yes I read that article too. And it confirms that, in theory, you cannot load data from another domain using IE.

However I have code that does just that and it works fine (so you can access data from different domains using IE). So that rules is only sometimes true (which sounds like nonsense I know).

I have only tested the code on IE.

The problem is my new, refactored code - that *calls* the xml loading function/object has caused the xml loading function to throw the "Access is denied" error.

The xml loading function works fine when called from a simple test script (all on IE) - for data on both local and external domains.
However when called from my refactored code it works fine for local data - but throws the error when loading data from an external domain.
I hope that explains the problem a little better.

I'll no doubt need to refactor it all again to work with Firefox - and I'll be interested to see what happens then.

As the problem is inconsistent - my bets are that it is an IE anomoly/bug.

Many thanks
Tim
Left by Tim on May 18, 2006 6:01 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
bol=true;
if(bol)
{
//submitForm(this.form.id,99001,success,fail,conf);
alert("if bol");
document.RKSdetails.action="RKS_direct_defaults_input_submit.do";
alert("if ");
document.RKSdetails.submit();
alert("One record is saved");
}


Iam also getting this same problem while submit(); function calls , plz help me asap ,

send the queries to dkishore82@gamil.com
Left by kishore on Mar 04, 2007 1:15 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Every time i try to send a greeting card a pop up that tells me unable to acess Javascript void noil.I have Java on my computer.why is this? What do i do about?
Left by myra oden on Dec 13, 2007 9:33 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Try follwing steps:
STEP 1:
add both sites your sites as trusted sites
STEP 2:
a. In Internet Explorer, on the Tools menu, click Internet Options.
b. Click the Security tab, Click on trusted sites, then the Custom Level Button.
c. Scroll to Miscellaneous > Access Data across domains > Enable.

This solved problem for me.
Left by Pankaj rana on Mar 31, 2008 8:55 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
I got the solution for the javascript error
Its nothing the code error but the prorerties of IE 6...
Do thing follow your problem will be solved
If you are using IE then

1>Goto Tools

2>Internet Options

3>Security

4>Custom Level

5>Miscellaneous

6>Access data source across domain
Enable it


Sure ur problem will solved ...

If yes the sure dont forget to mail me will be wating for Ur mail .....
Left by Om Sharma on May 09, 2008 12:32 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
That worked perfectly for me, Om Sharma. Thanks!!
Left by Somer on May 17, 2008 1:11 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Hello everybody.

I have the same problem with "Access denied" when trying to load an xml.

I have tried to do the setting from IE6 browser, but still is not working :(.
Can anybody hep my, please?
Thank you
Left by Veronica on Jun 12, 2008 11:29 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
The solution above worked for me as well but that doesn't solve the issue as a developper since I cannot ask all my users to go through these steps in order to get my the page I developped to work. Most users will just think it's an error! Anyone know another way around this to force the browser to accomplish this?
Left by JJ on Jun 30, 2008 5:28 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
JJ this is a security 'feature' of most browsers. However I've heard that IE 8 will provide some functionality to support this behaviour as it is becoming a more popular thing to do.

That said, it is a security feature for a reason (eg to help reduce XSS). The way most well designed apps provide data from multiple sources (eg mashups) is to do the consumption/aggregation of external sources from your own server (rather than the client) - then output the results on the client.

Tim
Left by Tim Huffam on Jun 30, 2008 8:24 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Would this security feature get blocked if, say, the JS script was living on www.mysite.com and the XML that it was trying to load was on rss.mysite.com?
Left by Big T on Jul 23, 2008 8:18 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
I have an issue in loading external xml file, please note the following

<script language="javascript" type="text/javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("http://Externalserver.com//stusername.xml?ReadForm");
...
...

...

</script>

this javascript is working fine in html files, but in aspx page same script returning an error like 'msxml3.dll: Access is denied.' . I think my issue is not related to any browser security, because its working in html files.

any help will be appreciated...

eldho
Left by eldho on Oct 24, 2008 9:19 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Hello everybody.

I have the same problem with "Access denied".
I have tried to do the setting from IE6 browser, but still is not working .Can anybody hep my, please?
Thank you
PunyaKumar
Left by punyakumar on Sep 07, 2009 6:38 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
HI everybody

I have same problem "Access denied".

Thanks
Amna
Left by Amna on Dec 31, 2009 1:42 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
Hi everybody,
I have got problem with IE6 and IE8.Problem of searching window is not close down automatically.once i close it manually it shows me that error.
I made the application browser independent and i got this error when i am searching some data with IE8.
It is working fine with IE6 but not with IE8.
Could anyone encounter with such error.

Thanks in advance,
Vinay
Left by Vinay on Oct 25, 2010 1:16 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
I HAVE THE SAME PROBLEM WHEN I AM TRYING TO ACCESS A SERVLET USING AJAX....I HAVE ENABLED THAT ACCESS ACCROSS DOMAINS ETC....

CAN ANYBODY HELP ME FOR THIS ISSUE ??????
Left by Bharat Patel on Oct 27, 2010 5:10 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
There is a cross domain policy that is made so that you cannot load data from another domain. If you set your browser to load the data from another domain, then it will only work on your computer, since everyone elses computer will still have the security feature enabled.
When loading your own html pages on your computer, then it is a local file, and local domains do not have the same restrictions as compared to http domains.
Left by eh on Nov 18, 2010 8:17 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
put only
stusername.xml?ReadForm
ok?


I have an issue in loading external xml file, please note the following

<script language="javascript" type="text/javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("http://Externalserver.com//stusername.xml?ReadForm");
...
...

...

</script>

this javascript is working fine in html files, but in aspx page same script returning an error like 'msxml3.dll: Access is denied.' . I think my issue is not related to any browser security, because its working in html files.

any help will be appreciated...

eldho

Left by Celso Wellington on Dec 15, 2010 6:46 PM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
This makes no sense! I thought the whole point of xml was to allow data to be read easily across the internet!
Left by HowMuchIsGoldWorth on May 15, 2011 9:45 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...
I too had a same problem. I was using file component and calling from other component(original was hidden and using some button to call click event of file). So whenever i upload through this code. it is used give this error. when i set visible true for file component and uploaded document with the original file component, it worked fine.

summary is : when your code try to access compnent(object) not visible or known to your form, its gives error..
Hope this will help you all....
Left by nextcome on May 20, 2011 7:22 AM

# re: Access is denied - Javascript error when attempting to load xml from an external site.
Requesting Gravatar...

Hi all,
I am also facing same problem, i created one html page which call a rss using ajax.

xmlhttp.open("GET","http://weather.yahooapis.com/forecastrss?w=2295420",true);

this is working fine on local system, but when i deployed it on server, it is showing Access Denied.

Thanks for reply.. :)
Left by vivek Purohit on Jun 02, 2011 12:56 AM

Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net