Home >Web Front-end >JS Tutorial >Detailed explanation of examples of load() function in ajax application in jquery

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

黄舟
黄舟Original
2017-09-07 14:19:011558browse

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对象});

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!

Statement:
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