Doubt with Jquery Load

1

I have a menu that I will use on all pages, so I want to load the content:

I'm doing this:

<head>
    <meta charset="utf-8">
    <!-- This file has been downloaded from Bootsnipp.com. Enjoy! -->
    <title> </title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="./css/bootstrap.min.css" rel="stylesheet">
     <link href="./css/estilo.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script><scriptsrc="./js/bootstrap.min.js"></script>
    <link rel="icon" href="./favicon/favicon.png">

    <script>
      $("#menu").load("menusistema.html");
    </script>

</head>

<body">

    <div id="menu"></div>

</body>

You're not carrying anything, what could be wrong?

    
asked by anonymous 21.09.2017 / 20:18

2 answers

2
Ajax does not work in file:// protocol, you have to use a HTTP server like Apache or Ngnix, the message itself says this:

  

XMLHttpRequest can not load file: // ...

Translating:

  XMLHttpRequest can not load file: // ... cross-source requests ("different" sources) are only supported by protocols: http, date, chrome, chrome-extension, https, and chrome-extension-resource.

As I explained in:

And here is an explanation of what is Wamp, Xampp and etc:

So if you use PHP you can install:

  • link (windows, apache, php, mysql)
  • link (cross-platform, apache, php, mysql, pearl)

If you use asp.net-mvc then create a project by VS and upload your .html there.

    
21.09.2017 / 21:11
0

Use this as well

 <script>
        $(document).ready(function(){
      $("#menu").load("menusistema.html");
        });
    </script>

instead of your

<script>
      $("#menu").load("menusistema.html");
    </script>

    
05.06.2018 / 05:58