Load() Method in jQuery

The load() method used to loads data from a server and returned to selected element.

Example :

The following example show, how to load data from sample.txt file when clicked the button using jQuery load() method.

  <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
    <input type='button' value='Load Data' id='btn'>
    <div id='res'>
        $("#res").load("sample.txt",function(response, status, xhr){
Try it Yourself
<h1 style='font-size:20px;'>Hello World</h1>
<p style='color:green;'>Sample paragraph  from sample.txt file</p>
  <li>List Item 1</li>
  <li>List Item 2</li>
  <li>List Item 3</li>
  <li>List Item 4</li>
  <li>List Item 5</li>

Demo :