Home > Web Front-end > JS Tutorial > jQuery's load() method and its callback function usage example_jquery

jQuery's load() method and its callback function usage example_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:07:39
Original
1404 people have browsed it

The example in this article describes jQuery’s load() method and its callback function usage. Share it with everyone for your reference. The details are as follows:

The following js code demonstrates the use of jQuery's load() method, and demonstrates the use of the load method with callback function (callback)

<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
 $("button").click(function(){
  $("#div1").load("demo_test.txt",function(responseTxt,statusTxt,xhr){
   if(statusTxt=="success")
    alert("External content loaded successfully!");
   if(statusTxt=="error")
    alert("Error: "+xhr.status+": "+xhr.statusText);
  });
 });
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button>Get External Content</button>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template