473,410 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

error using XmlHttpRequest in Firefox

Hi, I am trying to develop a RSS reader using Ajax.
I use the following Get statement.
AjaxObject.open("GET",URL,true)
where URL is the location of my feed.
Now when I give URL as a file in my localhost directory, it works fine in both IE and Firefox.
But when give URL as a remote feed,it doesnt work in Firefox. It gives me an 'undefined' error.
I read somewhere that it could be because Firefox blocks cross-domain operations so I included the folowing statement in my Js file

try
{
netscape.security.PrivilegeManager.enablePrivilege ("UniversalBrowserRead");
}
catch(e)
{
alert("Permission UniversalBrowserRead denied.");
}

But it still goes into the catch mode...

Any idea on how to solve this problem?
Help would be greatly appreciated.
Thanks
May 22 '07 #1
3 1884
dmjpro
2,476 2GB
can u send me ur js code where u make the request.
then i think it ll be better to solve ur problem.

kind regards.
dmjpro.
May 22 '07 #2
Hi,
Thanks for your reply..
Here is my code..


Expand|Select|Wrap|Line Numbers
  1. url="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml";
  2. function getRSS()
  3.     { 
  4.     if (window.ActiveXObject)
  5.         {
  6.         ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");
  7.         alert("microsoft xmlhttp");
  8.         }
  9.     else if (window.XMLHttpRequest)
  10.         {
  11.         ajaxobj = new XMLHttpRequest();
  12.         if (typeof netscape != 'undefined' && typeof netscape.security !=             'undefined') 
  13.                 {
  14.                  try {
  15.           netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
  16.                      }
  17.                 catch (e) {
  18.                                alert('Error ' + e.message + ' occurred.');
  19.                              }
  20.          }
  21.  
  22.            alert("xmlhttprequest");
  23.          }
  24.     else
  25.         alert("not supported");
  26.  
  27.     try
  28.     {
  29.     ajaxobj.open("GET",url+"?sid="+Math.random(),true);
  30.     }
  31.     catch(error)
  32.     {
  33.      alert("catch"+ error.description);   //script doesnt go beyond this in Firefox
  34.      return false;
  35.      }
  36.        ajaxobj.onreadystatechange = function() {
  37.         if (ajaxobj.readyState == 4)
  38.         {
  39.             if (ajaxobj.status == 200)
  40.             {
  41.                 if (ajaxobj.responseText != null)
  42.                 {
  43.                 processRSS(ajaxobj.responseXML);
  44.                 }
  45.                 else
  46.                 {
  47.                  alert("Failed to receive RSS file from the server - file not found.");
  48.                 return false;
  49.                 }
  50.             }
  51.          else
  52.             alert("Error code " + ajaxobj.status + " received: " + ajaxobj.statusText);
  53.          }
  54.     }
  55.  
  56.     ajaxobj.send(null);
  57.     }
  58.  
  59.  
May 22 '07 #3
acoder
16,027 Expert Mod 8TB
To get around the security (same domain), use JSON, e.g. link.
May 23 '07 #4

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

Similar topics

9
by: David | last post by:
Hello I'm testing the XMLHttpRequest object in Firefox and IE. The code below works well in IE and Firefox. It shows "1" when the string is a number and "0" when not. The page aspxTest.aspx only...
10
by: Matt Kruse | last post by:
I'm aware of the circular reference memory leak problem with IE/closures. I'm not sure exactly how to resolve it in this situation. Also, Firefox appears to grow its memory size with the same code....
12
by: knocte | last post by:
Hello. I have always thought that the eval() function was very flexible and useful. If I use it, I can define functions at runtime!! However, I have found a case where eval() does not work...
1
by: mubarak basha | last post by:
hi, i wrote the following coding.......... <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Getting...
13
by: TLaufenberg | last post by:
I'm new to Javascript programming and I've run into a bit of a snag with making an XMLHttpRequest in the Safari browser. Actually, the request doesn't work in Firefox either but only when I use a...
1
by: shankwheat | last post by:
I use this code to populate a selectbox with a group of records from a database. It executes very quickly with FireFox 2.0 but takes 7-10 secs with IE6 and IE7. Just wondering if anyone had any...
2
by: kpg | last post by:
I have an AJAX enabled web service consumed by an AJAX enabled web app, given a zip code it returns the city and state. Tested the web service, it works fine. I created a services collection...
1
by: Iain Adams | last post by:
My code is as follows. http_request = false; if (window.XMLHttpRequest) { alert("firefox"); http_request = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { alert("ie");
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.