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 7752097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:42:47+00:00 2026-06-01T11:42:47+00:00

I am making a simple javascript application where I need to load an xml

  • 0

I am making a simple javascript application where I need to load an xml files and show them in front of the user. but my code only works in Mozilla Firefox but when it comes to chrome and Internet Explorer they are not working. I am loading my XML document in a local machine.

$(document).ready(function() {
    $('.buttons').slideToggle('medium');

    $.ajax({ 
    url: "dictionary.xml", 
    success: function( xml ) { 
        $(xml).find("word").each(function(){ 
            $("ul").append("<li>" + $(this).text() + "</li>");
        }); 
   } 
    });
}

And Here’s my XML

 <?xml version="1.0" encoding="UTF-8"?> 
  <xml> 

    <word> 
      <threeletter>RIP</threeletter> 
      <fourletter>PIER</fourletter>
      <fiveletter>SPIRE</fiveletter> 
      <sixletter>SPIDER</sixletter> 
     </word>

     <word> 
      <threeletter>SUE</threeletter> 
      <fourletter>EMUS</fourletter>
      <fiveletter>SERUM</fiveletter> 
      <sixletter>RESUME</sixletter> 
     </word>

     <word> 
      <threeletter>COO</threeletter> 
      <fourletter>CON</fourletter>
      <fiveletter>CONDO</fiveletter> 
      <sixletter>CONDOM</sixletter> 
     </word>

    </xml>

I found the error, here it is

XMLHttpRequest cannot load file:///C:/Users/John/Desktop/JsTwist/dictionary.xml. Origin null is not allowed by Access-Control-Allow-Origin.
  • 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-06-01T11:42:48+00:00Added an answer on June 1, 2026 at 11:42 am

    Google Chrome doesn’t allow AJAX requests over the file:// protocol by default.

    You’ll need to start Chrome with the --allow-file-access switch.

    Here are instructions for supplying switches on each OS.

    I’m not sure how to enable the file protocol for IE.

    Possibly the easiest thing to do is to setup a local web server and run your app along with the xml files in it, then you don’t have to worry about this issue in either browser.

    edit

    Late edit, I know. I wanted to throw this out there in case others have an issue.

    When requesting an xml document with jQuery, you should always supply a dataType in the settings object. Internally, jQuery does it’s best to guess at what is returned and I’ve had it consider a perfectly good xml document to be HTML/XHTML.

    To do this, add dataType: “xml”. For example:

    $(document).ready(function() {
        $('.buttons').slideToggle('medium');
    
        $.ajax({ 
            url: "dictionary.xml", 
            success: function( xml ) { 
                $(xml).find("word").each(function(){ 
                    $("ul").append("<li>" + $(this).text() + "</li>");
                }); 
            },
            dataType: "xml"
        });
    }
    

    Supported data types are available on the documentation page for jQuery.ajax().

    In addition, I’ve encountered the Access-Control-Allow-Origin error above when trying to fetch an RSS feed from a remote server. The only way I’ve determined to get around this is to proxy request the RSS feed from the server-side code and deliver it via some proxy script. Here’s a simple example in PHP:

    <?php
    
     if(isset($_GET['q']) && isAjax())
     {
        $q = strip_tags($_GET['q']);
        header("Status: 200");
        header("Content-type: text/xml");
        echo  file_get_contents('http://'.$q);   
        exit();
     }
    
    function isAjax() {
        return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 
        ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
    }
    
    ?>
    

    CAVEAT I highly recommend modifying the above script to allow only those locations you plan to serve to your client code by validating q or by further restricting the isAjax function. I’m not a PHP developer and I don’t pretend to know best practices for PHP security. If anyone has suggestions to improve the PHP snippet, I’d happily apply them.

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

Sidebar

Related Questions

I'm making a simple app that will load a google map. but the problem
I'm making a simple game in Javascript, in which when an object collides with
I started making this simple google chrome extension in javascript. And in the beginning
I'm making a simple javascript app that needs to run locally (on a CD
When making a simple WYSIWYG editor with JavaScript for a textarea I can check
I'm making a webapp and I'm using jQuery. I've made a simple android application
i'm making a simple app that asks a remote server via webbrowser, but, if
I'm probably making a really simple error somewhere, but for some reason the event
I'm making a simple JavaScript graphing library using the canvas element. I really suck
I am making a simple JavaScript based WYSIWYG editor using regular expressions to do

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.