Get text from a txt file in the url - Javascript jQuery

Javascript examples for jQuery:Text

Description

Get text from a txt file in the url

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
      <script>
$(document).ready(function(){
    $("button").click(function(){
        $.ajax({url: "test.txt", success: function(result){
            $("#div1").html(result);
        }});/*from  www.j a  v a  2 s  .  c o m*/
    });
});

      </script> 
   </head> 
   <body> 
      <div id="div1">
         <h2>Let jQuery AJAX Change This Text</h2>
      </div> 
      <button>Get External Content</button>  
   </body>
</html>

Related Tutorials