Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Excerpt

$(document).ready(function()) {} helps you to run certain javascript when the HTML page is fully loaded


Below example load text from the remote website asynchronously when the HTML page gets ready. 

Code Block
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $.ajax({url: "demo_test.txt", success: function(result){
      $("#div1").html(result);
    }});
  });
});
</script>
</head>
<body>
 
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
 
<button>Get External Content</button>