1

I am developing a website which loads html from a template page then loads content from XML. for instance these are called in the document.ready function

$.ajax({
                type : "GET",
                url : "template.html",
                dataType : "html",
                success : function(html) {
                    var ndoc = document.createElement('html');
                    ndoc.innerHTML = html;
                    page = $('body', ndoc);
                    $('body').html(page.html());

                    $.ajax({
                        type : "GET",
                        url : "XML/content.xml",
                        dataType : "xml",
                        success : function(xml) {
                            page = $(xml).find('chisiamo').find('dialogue')[0];

                            setupPage(page);
                        }
                    });

                }
            });

This works well in Firefox and Safari. But in Chrome i get a 'Origin null is not allowed by Access-Control-Allow-Origin' when it tries to load template.html. How can I solve this problem? thank you very much.

Lorenzo
  • 447
  • 1
  • 3
  • 21

3 Answers3

0

Try to start Google Chrome with this arguments :

google-chrome --disable-web-security --allow-file-access-from-files
Damoun
  • 346
  • 1
  • 5
  • I need to make this website work locally in google chrome. I am aware of the arguments you posted, but isn't there a way to change my request so it works with a standard Chrome without startup options? – Lorenzo Mar 07 '12 at 20:58
  • I don't think because it's a 'security'. Have you try to put your files in an http server ? – Damoun Mar 07 '12 at 21:02
0

You should be able to create a Chrome Web App and set the permissions in the manifest to allow it access to read files from the file:// scheme.

http://code.google.com/chrome/extensions/manifest.html

Brad Dwyer
  • 6,305
  • 8
  • 48
  • 68
  • can you please be more specific? I am really just approaching the whole compatibility thing and am pretty much clueless in this case. – Lorenzo Mar 07 '12 at 21:30
  • I managed to build the manifest and get the first HTML request working, but cannot still load from XML files. – Lorenzo Mar 07 '12 at 23:35
0

You have to add permissions to the page you are requesting in the manifest. Also try using $.getJSON instead ;)

jjNford
  • 5,170
  • 7
  • 40
  • 64