By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 2,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

Cross domain in Ajax

P: 3
I have written a Ajax code to get the data from the URL and i am able to get the output in the explorer but getting the below error in Mozilla firefox .Kindly anyone help me in this regards.

Security Error: Content at http://localhost:8084/......../Login.do may not load data from http://platts-lng.demo.marklogic.com/request.xqy.

Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://localhost:8084/......./javascript/home.js Line: 47"]

Expand|Select|Wrap|Line Numbers
  1. var xmlhttp;
  2.  
  3.             function loadXMLDoc()
  4.             {
  5.            try
  6.   {
  7.   // Firefox, Opera 8.0+, Safari
  8.   xmlhttp=new XMLHttpRequest();
  9. xmlhttp.overrideMimeType('text/xml');
  10.  
  11.  
  12.   }
  13. catch (e)
  14.   {
  15.   // Internet Explorer
  16.   try
  17.     {
  18.     xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  19.  
  20.     }
  21.   catch (e)
  22.     {
  23.     try
  24.       {
  25.       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  26.  
  27.       }
  28.     catch (e)
  29.       {
  30.       alert("Your browser does not support AJAX!");
  31.       return false;
  32.       }
  33.     }
  34.   }
  35.             var url=document.getElementById('url').value+"/request.xqy"
  36.             parameters="action=search&scope=tracker-unpublished";
  37.             xmlhttp.onreadystatechange=onResponse;
  38.             alert("Mozial level"+xmlhttp);
  39.             xmlhttp.open("POST",url,false,document.getElementById("userName").value,document.getElementById("password").value);
  40.             xmlhttp.send(parameters);
  41.             }
  42.  
  43.             function onResponse()
  44.             {
  45.             if(xmlhttp.readyState!=4) return;
  46.             if(xmlhttp.status!=200)
  47.             {
  48.             alert("Problem: " + xmlhttp.statusText);
  49.             return;
  50.             }
  51.  
Oct 14 '08 #1
Share this Question
Share on Google+
9 Replies


rnd me
Expert 100+
P: 427
i can help.

you can't do it for public sites.

if this is just to make an app for yourself, you can modify firefox's about:config to allow these transactions in that one browser.
Oct 14 '08 #2

P: 3
i can help.

you can't do it for public sites.

if this is just to make an app for yourself, you can modify firefox's about:config to allow these transactions in that one browser.




Kindly let me know the complete path for this where i can make changes for firefox.
Oct 15 '08 #3

freddieMaize
P: 85
Kindly let me know the complete path for this where i can make changes for firefox.
I've been trying to do this for ages?? Kindly let me know how to go about?? WOuld be of great help...

fREDDIE
Oct 15 '08 #4

rnd me
Expert 100+
P: 427
I've been trying to do this for ages?? Kindly let me know how to go about?? WOuld be of great help...

fREDDIE

ok guys. here you go:

1. navigate to about:config
2. change 'signed.applets.codebase_principal_support' to true
3. use the function below to perform cross-site requests.
Expand|Select|Wrap|Line Numbers
  1.  
  2. function IOx(U) {
  3. netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
  4.     var X = new XMLHttpRequest();
  5.     X.open( 'GET', U, false);
  6.     X.overrideMimeType('text/html');
  7.     X.send(''); 
  8.   return X.responseText
  9. }
  10.  
  11.  
  12.  alert(IOx("http://google.com"))
  13.  
  14. //shows:<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Google</title> ...
  15.  
  16.  
you can copy and paste a duplicate, renamed version that returns the responseXML if you need it. you can modify to use POST or PUT if you need as well. this is only a simple example.

click "allow" on the security dialog. you probably want to also check "Remember this decision." to avoid repeated allow clicking on your site


one last note: the about:config change you made can potentially allow any site increased privileges. it will always ask for permission first however. so, if you are at illegal-porn.net (or whatever), and you see the pop-up, do yourself a favor and click "deny".



this can turn your copy of firefox into much more of an application environment rather than a browsing environment.
Oct 15 '08 #5

iam_clint
Expert 100+
P: 1,208
You may also look into server side ajax.. not sure what you are using ajax for in this case but sometimes you just need info from another page when the page loads.. in that case you can do server side.
Oct 15 '08 #6

P: 3
Thanks for all your kind replays .

I stuck with one more thing as i am getting this below alert on regular basis on interner explorer

"This page is accessing information that is not under its control.This poses a security risk.Do you want to continue?"

If i say yes than only the content of the page are displaying .If i say no than nothing is displaying in the page .

I no how to disable this security alert from the browser level
Tools-interner option-security-Custom Level-Miscellaneous-disable
But i can't say the clinet to do this So kindly help me how can i do this from code level.
Oct 16 '08 #7

gits
Expert Mod 5K+
P: 5,328
you shouldn't use the shown solution for a public site ... you cannot rely on browser-settings and you should avoid to force a user to set his security-settings in a way you would like to have it ... and you fortunatly cannot set it without asking the user for permission to do so ...

for public sites you need something like a serverside page proxy that works around the cross domain issue ...

kind regards
Oct 16 '08 #8

acoder
Expert Mod 15k+
P: 16,027
I no how to disable this security alert from the browser level
Tools-interner option-security-Custom Level-Miscellaneous-disable
But i can't say the clinet to do this So kindly help me how can i do this from code level.
This is not possible and quite rightly so. If it could be possible to change security settings using code, it'd make the settings quite redundant.
Oct 16 '08 #9

P: 4
Thank rnd me...

I spent my whole day to find how to call web service using mozilla.
Apr 10 '10 #10

Post your reply

Sign in to post your reply or Sign up for a free account.