Usage and function of jQuery load ()

1, load () syntax

$(selector).load(URL,data,callback);

2, load () instance

$("button").click(function(){
$("#div1").load("demo_test.txt",function(responseTxt,statusTxt,xhr){
if(statusTxt=="success")
alert("外部内容www.nanaopearl.com加载成功!");
if(statusTxt=="error")
alert("Error: "+xhr.status+": "+xhr.statusText);
});
});

3, load function

In order to avoid code duplication in the case of multiple pages, you can use the load () method to put the repeated parts (such as the navigation bar) into a separate file,

Guess you like

Origin www.cnblogs.com/96net/p/12694694.html