0

I'm not sure why suddenly it's not loading content from other html document.

$('a').on('click', function(e){
    e.preventDefault();

    $.get('page1.html', function(data){
        var content = $('#result', data).html();
        console.log(content);
    });

});

<a href="#">Load Page</a>

It was loading the content inside the div called #result in page1.html before, I don't know what I have changed but it's not working now.

console.log

XMLHttpRequest cannot load file:///I:/page1.html. Received an invalid response. Origin 'null' is therefore not allowed access. 
Dale A. Almaraz
  • 183
  • 1
  • 1
  • 12
  • You need to put the files on a server. You're viewing the files from your filesystem and your browser is protecting you from loading resources on your system to the webpage. If you don't have a server then you can install one on to your computer for testing usage. I use [Xampp](https://www.apachefriends.org/index.html) on windows and [Ampps](http://www.ampps.com/) on mac. – Adam Merrifield Aug 05 '14 at 23:22
  • possible duplicate of [XMLHttpRequest Origin null is not allowed Access-Control-Allow-Origin for file:/// to file:/// (Serverless)](http://stackoverflow.com/questions/4208530/xmlhttprequest-origin-null-is-not-allowed-access-control-allow-origin-for-file) – kritzikratzi Aug 05 '14 at 23:40
  • look at this question: http://stackoverflow.com/questions/4208530/xmlhttprequest-origin-null-is-not-allowed-access-control-allow-origin-for-file in general it's a good idea to copy&paste your error message into google before creating a new question. – kritzikratzi Aug 05 '14 at 23:42

1 Answers1

1

It seems in your console log that you are not using a server and for security reasons javascript(XMLHttpRequest) is not allowed to access local files of your computer

Here I:/page1.html is local filesystem address

That's why file is not being loaded.

Vinit Chouhan
  • 686
  • 1
  • 10
  • 23