title: how to save data in localstorage for further use?
body: <p>how can i save the data in localstorage each keyup and when i search again data will show from localstorage, this time do not sent any request for data from db.</p>
  
  <pre><code>$(document).ready(function () {
    $('#input_id').keyup(function (e) {
      var name = $('#input_id').val();
      var data = name.trim();
      var msg = $('#result');
      msg.empty();
  
      $.ajax({
        url: "search.php",
        method: "post",
        data: { input: data },
        dataType: "",
        success: function (name) {
        console.log(name);
        var getdata = JSON.parse(name);
        var z = getdata.length;
        for (var j = 0; j &lt; z; j++) {
          if (getdata[j].surname) {
            var show_result = '&lt;span id="result"&gt;' + getdata[j].firstname + " " + getdata[j].surname + '&lt;/span&gt;';
            msg.append(show_result);
          } else {
            var show_result2 = '&lt;span id="result"&gt;' + getdata[j].firstname + '&lt;/span&gt;';
            msg.append(show_result2);
          }
        }
      }
    });
  });
  </code></pre>