function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
regger118regger118 

Using ajax to download xml file from another server

Hi Guys i am trying to download an xml file from a server using the xmlHtttpRequest object but i get an error is not allowed by Access-Control-Allow-Origin.

 

how can i get around this problem?

SoleesSolees
Are you using GET or POST? Please put your code here so i can see it.

Cheers
SoleesSolees

    var xmlhttp;
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        alert('IE7+, Firefox, Chrome, Opera, Safari');
        xmlhttp = new XMLHttpRequest();
    } else {// code for IE6, IE5
        alert('IE6, IE5');
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
        
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4) {
            alert('xmlhttp.responseText');
        }
    }

 

   var filePath = "www.somthing.com/file.xml";


    xmlhttp.open("GET", filePath, false);
    xmlhttp.setRequestHeader("Content-Disposition","inline; filename='"+filePath+"'");
    xmlhttp.setRequestHeader("Content-Transfer-Encoding","binary");
    xmlhttp.send(null);