Home > Web Front-end > JS Tutorial > body text

Detailed explanation of examples of load() function in ajax application in jquery

黄舟
Release: 2017-09-07 14:19:01
Original
1507 people have browsed it

The load() function of 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对象});
Copy after login

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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!