473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed with .js and AJAX

Hi all,
When using AJAX and javascript I get the following error when
talking to my server:

A script from http://www.mydomain.com was denied UniversalBrowse rRead
privileges. I am using firefox 1.5 and here is the code that is being
called:

function showConsumption Data(foodType) {
var url =
'http://mydomain.com/platePyramid.do ?foodType=' +
foodType+'&sysT ime='+new Date().getTime( );
if (window.XMLHttp Request) {
try {

netscape.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lBrowserRead");
req = new XMLHttpRequest( );
req.onreadystat echange = processSCReques t;
req.open("GET", url, false);
req.send(null);
}
catch (e)
{
alert("(Mozilla )-"+e);
}
} else if (window.ActiveX Object) {
req = new ActiveXObject(" Microsoft.XMLHT TP");
req.onreadystat echange = processSCReques t;
req.open("GET", url, false);
req.send(null);
}
}

The .js files is contained in its own file, being called by the .hrml
file. Could this be causing the problem? I am stumped. Any help would
be appreciated
Regards,

Steven H.

Dec 19 '05 #1
10 4409
Only reason to use the Privilege is for cross domain coding.

If you need it then you need to add the code in two places normally. I
wrote an example using it awhile back,
http://radio.javaranch.com/pascarell...=1120688860820

See if that gives you any light into the problem.

Eric Pascarello
Coauthor of Ajax In Action

Dec 19 '05 #2


sheadley wrote:

A script from http://www.mydomain.com was denied UniversalBrowse rRead
privileges. I am using firefox 1.5 and here is the code that is being
called:

function showConsumption Data(foodType) {
var url =
'http://mydomain.com/platePyramid.do ?foodType=' +
foodType+'&sysT ime='+new Date().getTime( );
if (window.XMLHttp Request) {
try {

netscape.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lBrowserRead");


You are calling enablePrivilege here but your code is not trusted and
therefore the call gives that message that the requested privilege
UniversalBrowse rRead was denied.
With normal security settings code in a HTML document loaded from a HTTP
server is not not able to enable privileges, you would need to use
signed script.
Why do you need that call, or why do you think you need it?

If your HTML document with the script comes from
http://www.mydomain.com/ then your XMLHttpRequest object should be able
to access URLs on www.mydomain.com without any need to enable privileges.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 19 '05 #3
when I don't use the following code:
netscape.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lBrowserRead
");
I get the following error:

XMLHttpRequest. open() failed permission denied.
I am using jboss and struts to server up these pages would that have an
impact??

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '05 #4
VK

Steven Headley wrote:
I am using jboss and struts to server up these pages would that have an
impact??


JBOSS or Perl script - it doesn't matter. What is matter is

(1) Same domain rule:

1) HTML page
2) .js script file
3) URL your're calling with AJAX
-----------------------
all three components have to be from the same domain where the "same
domain" means same protocol (http or https but not a mix), same
subdomain, same domain name and same first level domain:
[http://] [www.] [mycompany] [.com]
from above all squared components can be different or missing but it
has to be *identical* for all three sources (page, script, server call)

If it is true then you can at least use AJAX to call the server.

(2) If it is not true, or if you want to have extended privileges like
UniversalBrowse rRead:

Firefox implements three-tier security model from Netscape 4.x (but in
Firefox it is not Java, but native C++ code inside):

1) First all scripts *and pages* have to be contained in a signed .jar
file. The file has to be signed by a valid certificate. If it is, it
still doesn't give it any privileges: it only gives *a privilege to ask
for a privilege*.

2) over netscape.securi ty.PrivilegeMan ager methods your script asks for
a privilege. If the tier 1 above is passed OK, user will see the popup
asking for privilege. If tier 1 was not passed, no popup will be shown
and request will be automatically cancelled.

3) You using later JavaScript methods to access normally unavailable
information. Each method will ask every time for a privilege from
PrivilegeManage r on tier 2 above. But user will not be bothered anymore
with popups. If user granted privilege on tier 2, she also granted the
privilege to PrivilegeManage r to grant privileges to all methods on
tier 3.

More info and a working sample can be found here:
<http://www.mozilla.org/projects/security/components/signed-scripts.html>

Dec 19 '05 #5
VK

Steven Headley wrote:
I am using jboss and struts to server up these pages would that have an
impact??


JBOSS or Perl script - it doesn't matter. What is matter is

(1) Same domain rule:

1) HTML page
2) .js script file
3) URL your're calling with AJAX
-----------------------
all three components have to be from the same domain where the "same
domain" means same protocol (http or https but not a mix), same
subdomain, same domain name and same first level domain:
[http://] [www.] [mycompany] [.com]
from above all squared components can be different or missing but it
has to be *identical* for all three sources (page, script, server call)

If it is true then you can at least use AJAX to call the server.

(2) If it is not true, or if you want to have extended privileges like
UniversalBrowse rRead:

Firefox implements three-tier security model from Netscape 4.x (but in
Firefox it is not Java, but native C++ code inside):

1) First all scripts *and pages* have to be contained in a signed .jar
file. The file has to be signed by a valid certificate. If it is, it
still doesn't give it any privileges: it only gives *a privilege to ask
for a privilege*.

2) over netscape.securi ty.PrivilegeMan ager methods your script asks for
a privilege. If the tier 1 above is passed OK, user will see the popup
asking for privilege. If tier 1 was not passed, no popup will be shown
and request will be automatically cancelled.

3) You using later JavaScript methods to access normally unavailable
information. Each method will ask every time for a privilege from
PrivilegeManage r on tier 2 above. But user will not be bothered anymore
with popups. If user granted privilege on tier 2, she also granted the
privilege to PrivilegeManage r to grant privileges to all methods on
tier 3.

More info and a working sample can be found here:
<http://www.mozilla.org/projects/security/components/signed-scripts.html>

Dec 19 '05 #6
VK

Steven Headley wrote:
I am using jboss and struts to server up these pages would that have an
impact??


JBOSS or Perl script - it doesn't matter. What is matter is

(1) Same domain rule:

1) HTML page
2) .js script file
3) URL your're calling with AJAX
-----------------------
all three components have to be from the same domain where the "same
domain" means same protocol (http or https but not a mix), same
subdomain, same domain name and same first level domain:
[http://] [www.] [mycompany] [.com]
from above all squared components can be different or missing but it
has to be *identical* for all three sources (page, script, server call)

If it is true then you can at least use AJAX to call the server.

(2) If it is not true, or if you want to have extended privileges like
UniversalBrowse rRead:

Firefox implements three-tier security model from Netscape 4.x (but in
Firefox it is not Java, but native C++ code inside):

1) First all scripts *and pages* have to be contained in a signed .jar
file. The file has to be signed by a valid certificate. If it is, it
still doesn't give it any privileges: it only gives *a privilege to ask
for a privilege*.

2) over netscape.securi ty.PrivilegeMan ager methods your script asks for
a privilege. If the tier 1 above is passed OK, user will see the popup
asking for privilege. If tier 1 was not passed, no popup will be shown
and request will be automatically cancelled.

3) You using later JavaScript methods to access normally unavailable
information. Each method will ask every time for a privilege from
PrivilegeManage r on tier 2 above. But user will not be bothered anymore
with popups. If user granted privilege on tier 2, she also granted the
privilege to PrivilegeManage r to grant privileges to all methods on
tier 3.

More info and a working sample can be found here:
<http://www.mozilla.org/projects/security/components/signed-scripts.html>

Dec 19 '05 #7
VK

Steven Headley wrote:
I am using jboss and struts to server up these pages would that have an
impact??


JBOSS or Perl script - it doesn't matter. What is matter is

(1) Same domain rule:

1) HTML page
2) .js script file
3) URL your're calling with AJAX
-----------------------
all three components have to be from the same domain where the "same
domain" means same protocol (http or https but not a mix), same
subdomain, same domain name and same first level domain:
[http://] [www.] [mycompany] [.com]
from above all squared components can be different or missing but it
has to be *identical* for all three sources (page, script, server call)

If it is true then you can at least use AJAX to call the server.

(2) If it is not true, or if you want to have extended privileges like
UniversalBrowse rRead:

Firefox implements three-tier security model from Netscape 4.x (but in
Firefox it is not Java, but native C++ code inside):

1) First all scripts *and pages* have to be contained in a signed .jar
file. The file has to be signed by a valid certificate. If it is, it
still doesn't give it any privileges: it only gives *a privilege to ask
for a privilege*.

2) over netscape.securi ty.PrivilegeMan ager methods your script asks for
a privilege. If the tier 1 above is passed OK, user will see the popup
asking for privilege. If tier 1 was not passed, no popup will be shown
and request will be automatically cancelled.

3) You using later JavaScript methods to access normally unavailable
information. Each method will ask every time for a privilege from
PrivilegeManage r on tier 2 above. But user will not be bothered anymore
with popups. If user granted privilege on tier 2, she also granted the
privilege to PrivilegeManage r to grant privileges to all methods on
tier 3.

More info and a working sample can be found here:
<http://www.mozilla.org/projects/security/components/signed-scripts.html>

Dec 19 '05 #8
"Steven Headley" <st************ @yahoo.com> wrote in message
news:Mc******** *********@news. uswest.net...
when I don't use the following code:
netscape.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lBrowserRead
");
I get the following error:

XMLHttpRequest. open() failed permission denied.

In your original post, you said that your script (and pages) was coming from
http://www.mydomain.com, but your code calls http://mydomain.com.

Even if thos two resolves to the same ip-address, they are not seen as the
same domain from the browsers point of view.

I am using jboss and struts to server up these pages would that have an
impact??

no

--
Dag.
Dec 20 '05 #9

Steven Headley wrote:
I get the following error:

XMLHttpRequest. open() failed permission denied.


You need to make sure that you only access URLs from the same origin, if
you can't do that then install some server-side "URL fetcher" script so
that you can make all requests to the original server passing the URL on
another server in the query string where the server-side script then
makes the access to the other servers and returns the result to your
client-side code.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2579
by: Daves | last post by:
Hi, I'm using a asp.net 2.0 website to send out emails to users, the amount of which can reach up to 1500 users. Obviously the code sending the emails has to let the client know the mails are being sent out and display some kind of progress indicator. How would you implement this? Back in old asp 3.0 days I had a blank page where code did a...
4
1359
by: inspiretechnologies | last post by:
Hi all, I'm creating a Php page with connection to a MySql database. In this page, I get all the articles (text) of a member, and when the article's length exceeds 500 characters, a link "read more" is shown. I must implement with Ajax a function that allows, when the link "read more" is clicked, to show the rest of the article. It's a sort...
1
1332
by: Von Shean | last post by:
I have a website that i have migrated VS 2003 to VS 2005. I have done some work like adding master pages and making rest of the pages as content pages. However, now i want the site to be completly Ajaxed. I have a asp.net 2.0's menu control in my master page. I need the ContentPlaceHolder should only get refreshed when i select any...
0
1291
by: John Dufour | last post by:
AJAX Consultant Top NY newspaper is seeking a candidate who is confident about building and extending a personalization platform for xxxx.com, a site with an unparalleled combination of scale and complexity. You have extensive experience programming in a UNIX/Linux environment. The ideal candidate is a self starter who will pick up...
2
1092
by: Ken1 | last post by:
Hello, I want to upgrade my form filling process and make it user interactive. From what i've been reading i guess I need to use AJAX for this to work. I want to do simple stuff like user entering the username upon registration and the page tells him right away whether the input is valid and whether this username is already taken without...
0
5532
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
2
1679
by: DurgaKar1780 | last post by:
Hi All, I have an requirement in my project, where i have to show a pop up with an moving icon when a button is clicked. But the problem is that the pop up should close automatically once we get the response from webservice. So i wanted to go with ajax as i far as my knowledge goes we also wanted asynchronous calls to the server side code to know...
53
8330
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script language="javascript" type="text/javascript">
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7423
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.