Jquery load function does not work

Asked

Viewed 742 times

0

Even following the official documentation of Jquery, my script does not work. Something from day to day. I do not know if I changed something unintentionally.

Follows code below

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>load demo</title>
  <style>
  body {
    font-size: 12px;
    font-family: Arial;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<b>Projects:</b>
<ol id="new-projects"></ol>

<script>
$( "#new-projects" ).load( "load.html #projects li" );
</script>

</body>
</html>
  • I have moved the Jquery file to the latest.
  • I’ve tried it in different browsers
  • I have checked similar topics (not so similar)

Is there an AJAX restriction to load Estatic pages? I don’t know what’s going on. I don’t want to run a page dynamically next to the server (php) because I’m developing an Html5 mobile app. I know there are ways to run php on a smartphone. I don’t want to!

  • I’ve never used it that way but... try just $( "#new-Projects" ).load( "load.html" ); and see if it works...

2 answers

3


It doesn’t work if you are opening the file directly from disk.

The protocol does not support Cross-Origin, will only be able to run this example using a server http

Reference response: https://stackoverflow.com/a/10752078/5325043

  • 1

    Problem solved! Cause: Ignorance about AJAX. By a misinterpretation of the AJAX technique, I associated it only as a client-side. Which is not true. I just put it in the Apache server folder that worked. For those who have the same problem, know that this Jquery function does not work outside a server.

  • 1

    If the answer was useful you can mark it as accepted, that way other people can know that the problem has been solved

  • Not only was it fixed, but I had a similar problem using Jquery Mobile. Marquei as fixed!

0

Problem solved! Cause: Ignorance about AJAX. By a misinterpretation I had of the AJAX technique, I associated it only as a client-side. Which is not true. I just put it in the Apache server folder that worked. For those who have the same problem, know that this Jquery function does not work outside a server.

About AJAX https://pt.wikipedia.org/wiki/AJAX_(program%C3%A7%C3%A3o)

About the Jquery Load function https://api.jquery.com/load/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.