1

I'm getting a 404 file not found when I try to include an html file into another html using jQuery. Here's my code inside my index.html

<script> 
    $(function(){
      $("#portfolio").load("list.html"); 
    });
</script> 

The way my file directory is setup is that both index.html and list.html are within a views folder and being served via a node.js server.

6
  • Try "/list/list.html" Commented Jan 7, 2016 at 0:56
  • Can you show the contents of your index.html file was well? Commented Jan 7, 2016 at 0:56
  • Are you sure index.html is in that directory? Commented Jan 7, 2016 at 0:58
  • Oh shoot sorry I made a typo. I meant both index.html and list.html are within a "views" folder, not a "list" folder. Commented Jan 7, 2016 at 1:00
  • @axlj what difference does it make what is in the file? How does that help resolve a path problem? Commented Jan 7, 2016 at 1:10

1 Answer 1

2

The docs explains that you may use a callback parameter on the load method, which gives your information about the load request.

$( "#portfolio" ).load( "/list.html", function( response, status, xhr ) {
  if ( status == "error" ) {
    var msg = "Sorry but there was an error: ";
    $( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
  }
});

Also, you may check the Network tab of your browser´s Developer Tools to get more information, including URL that your script tried to reach. Debug from there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.