Cross Site XMLHTTP Request in Firefox

From Code Trash
Jump to: navigation, search
<script type="text/javascript" language="javascript">
 
// Error: uncaught exception: Permission denied to call method XMLHttpRequest.open
 
  var http_request = false;
 
  function makeRequest(url, parameters) {
 
   try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {
    alert("Permission UniversalBrowserRead denied.");
   }
 
    http_request = false;
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
      http_request.overrideMimeType('text/xml');
    }
    if (!http_request) {
      alert('Cannot create XMLHTTP instance');
      return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
  }
 
  function alertContents() {
    if (http_request.readyState == 4) {
      if (http_request.status == 200) {
 
        var string = http_request.responseText;
      alert(string);
 
      } else {
        alert('There was a problem with the request.');
      }
    }
  }
  function updateweather() {
    makeRequest('http://www.wunderground.com/auto/rss_full/global/stations/16239.xml', '');
  }
</script>


<input type="button" name="button" value="GET XML" 
  onclick="javascript:updateweather();">