Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:20:14+00:00 2026-05-28T00:20:14+00:00

I would like to know how do i use Access-Control-Allow-Origin ? In fact, i

  • 0

I would like to know how do i use Access-Control-Allow-Origin ?

In fact, i try to load xml data from a distant file into a html (into a ) but i have this mistake during the request :

XMLHttpRequest cannot load http://www.mysite.net/douce/bonsplans.xml. Origin http://mysite.net is not allowed by Access-Control-Allow-Origin.

Thanks for your reply


Mmmm, ok, so i think that is not possible for me to use this method. Here is my source code :

mypage.html :

<html lang="fr">
<head>
<title>monsite</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript" src="script.js"></script>

<SCRIPT TYPE="text/javascript">
        function init(){
        loadXMLDoc('http://www.monsite.net/bonsplans.xml');
        }
</SCRIPT>

</head>

<body onload="init();" onunload="clear();">

<div id="bonplans" class="panel4" title="Bons plans">
        <p style="text-align:left;"><font color="#4e559c" size="3px"><b>Dernières minutes :</b></font></p>
        <div id="writeDernieresMinutes"></div>
        <p style="text-align:left;"><font color="#4e559c" size="3px"><b>Offres permanentes :</b></font></p>
        <div id="writeOffresPermanentes"></div> 
</div>

</body>
</html>

And here is the script.js file :

function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
    xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)

 {
    dernieresminutes="";
    x=xmlhttp.responseXML.documentElement.getElementsByTagName("DERNIEREMINUTE");
    for (i=0;i<x.length;i++)
      {
      xx=x[i].getElementsByTagName("DATE");
        {
        try
          {
          dernieresminutes=dernieresminutes + "<fieldset><legend><font color='#4e559c' size='2px'>" + xx[0].firstChild.nodeValue + "</font></legend>";
          }
        catch (er)
          {
          dernieresminutes=dernieresminutes + "<p>erreur*</p>";
          }
        }
        xx=x[i].getElementsByTagName("CONTENT");
        {
        try
          {
          dernieresminutes=dernieresminutes + "<div class=\"row\"><font color='blue' size='3px'><center>" + xx[0].firstChild.nodeValue + "</center></font>";
          }
        catch (er)
          {
          dernieresminutes=dernieresminutes + "<p>erreur*</p>";
          }
        }
        dernieresminutes=dernieresminutes + "</font></div></fieldset>";
      }
    document.getElementById('writeDernieresMinutes').innerHTML=dernieresminutes;
  } 



  {
    OffresPermanentes="";
    x=xmlhttp.responseXML.documentElement.getElementsByTagName("OFFREPERMANENTE");
    for (i=0;i<x.length;i++)
      {
      xx=x[i].getElementsByTagName("TITRE");
        {
        try
          {
          OffresPermanentes=OffresPermanentes + "<fieldset><legend><font color='#4e559c' size='2px'>" + xx[0].firstChild.nodeValue + "</font></legend>";
          }
        catch (er)
          {
          OffresPermanentes=OffresPermanentes + "<p>erreur*</p>";
          }
        }
        xx=x[i].getElementsByTagName("CONTENT");
        {
        try
          {
          OffresPermanentes=OffresPermanentes + "<div class=\"row\"><font color='blue' size='3px'><center>" + xx[0].firstChild.nodeValue + "</center></font>";
          }
        catch (er)
          {
          OffresPermanentes=OffresPermanentes + "<p>erreur*</p>";
          }
        }
        OffresPermanentes=OffresPermanentes + "</font></div></fieldset>";
      }
    document.getElementById('writeOffresPermanentes').innerHTML=OffresPermanentes;
  }




}
xmlhttp.open("POST",url,true);
xmlhttp.send();
}



function getXhr(){
    var xhr = null; 
    if(window.XMLHttpRequest) // Firefox et autres
        xhr = new XMLHttpRequest(); 
    else if(window.ActiveXObject){ // Internet Explorer 
        try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    else { // XMLHttpRequest non supporté par le navigateur 
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
        xhr = false; 
    } 
    return xhr
}

So i fact, during the loading of mapage.html, the script must load the xml file from a distant source, parse it and write the content into the .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:20:15+00:00Added an answer on May 28, 2026 at 12:20 am

    In the response from mysite.net it would have to include a header with:

    Access-Control-Allow-Origin: [domain from where you're calling]

    (So, if you’re thissite.com, it would be Access-Control-Allow-Origin: thissite.com)

    or

    Access-Control-Allow-Origin: * (this would allow from all).

    If you don’t run mysite.net then there is no way to do this and you’ll have to come with alternate means to obtain this data. (Unless you can get them to supply the data in JSONP, your best bet is to write server side code to retrieve it that runs on the same domain as the HTML file you want to present it in, and then use an XHR to obtain that data.)

    If you need help adding headers to server responses, we need to know what HTTP server you’re using and if you’re using any sort of scripting language in conjunction with that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET MVC Preview 4 and would like to know how to use
I would like to know what kind of tool you use for writing your
I would like to know how to make use of an Axiom database resource
I would like to know what I should use to compile in C. I
I would like to know if I can use the following JQuery function on
I would like to know how can I use tinyint in SQL Server 2005
I would like to know how can I use jQuery to select multiple items
I would like to know a few practical use-cases (if they are not related/tied
I would like to know, if I use WndProc in my C#.net app to
I have a generator and I would like to know if I can use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.