Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Jquery ajax

// this page loads the file "data.txt" when the button is clicked.
// This file is index.php.
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
      $("#btn").click(function() {
        $("#content").load("data.txt");
      });
    })
  </script>
</head>

<body>
  <div id="content"></div>
  <br>
  <button id="btn">Press Me</button>
</body>
</html>
Source by careerfoundry.com #
 
PREVIOUS NEXT
Tagged: #Jquery #ajax
ADD COMMENT
Topic
Name
3+5 =