Home >Web Front-end >JS Tutorial >Detailed explanation of examples of load() function in ajax application in jquery
$(selector).load(URL,data,callback) function usually obtains the static files of the server. Selectors can be added to the URL for filtering.
The code is as follows:
$("#p1").load("data/demo_test.html #p1",function(){ //将远程文件的内容中的id=p1的元素加载到p1中,并调用回调函数。}); $("#p1").load("test.jsp",{name:"name1",age:"22"}, function(responseTxt,textStatus,XMLHttpRequest){ //可以向远程路径传递参数,返回数据,load的发送方式就根据有无数据决定,有数据就是post方式,没有就是get方式 //responseTxt; //请求返回的内容 //textStatus; //请求状态 success、error、notmodified、timeout //XMLHttpRequest; //XMLHttpRequest对象});
The above is the detailed content of Detailed explanation of examples of load() function in ajax application in jquery. For more information, please follow other related articles on the PHP Chinese website!