0

The divisions in the below code are not sortable when the code is run outside localhost.

<html>
<head>
  <style>
    div {
      width: 100;
      border: solid black 1px;
      text-align: center
    }
  </style>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
    $(function() {
      $("#sort").sortable({
        axis: "y"
      });
    });
  </script>
</head>
<body>
  <div id="sort">
    <div>1</div>
    <div>2</div>
    <div>3</div>
  </div>
</body>
</html>
Phoenix
  • 57
  • 9
  • IMO because you missed specify the protocol, the `https` in your second script src attribute. –  Nov 11 '17 at 18:12
  • @WaldemarIce [Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page](https://stackoverflow.com/questions/4978235/absolute-urls-omitting-the-protocol-scheme-in-order-to-preserve-the-one-of-the) – Andreas Nov 11 '17 at 18:15
  • yes u are right, thank you. – Phoenix Nov 11 '17 at 18:19
  • @Andreas It is safe enough for images, or css, but you never want to run unsafe way delivered scripts. Always use https protocol for scripts. –  Nov 11 '17 at 18:24
  • @WaldemarIce That's only an "it's possible" - no more, no less – Andreas Nov 11 '17 at 18:44
  • @Andreas Not always. If your page is delivered through https, you can't load additional scripts through http. –  Nov 11 '17 at 18:57

1 Answers1

0

you are missing https:// in script tag, replace it with:

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  • You can omit the protocol: [Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page](https://stackoverflow.com/questions/4978235/absolute-urls-omitting-the-protocol-scheme-in-order-to-preserve-the-one-of-the) – Andreas Nov 11 '17 at 18:13
  • can you tell me shortly why https was the issue and why it worked in localhost without it? – Phoenix Nov 11 '17 at 18:29
  • @mayank jain,@Andreas Thanks – Phoenix Nov 11 '17 at 18:44
  • Have a look at the first drawback in this answer. It specifies why you need to give http or https for resources when page is run outside localhost- https://stackoverflow.com/a/4832046/6261693 – Phoenix Nov 12 '17 at 06:31