Home  >  Article  >  Web Front-end  >  Introduction to the function of page Ajax method $.load in jquery_jquery

Introduction to the function of page Ajax method $.load in jquery_jquery

WBOY
WBOYOriginal
2016-05-16 16:33:211407browse

load syntax

$(".selector").load("url", function(responseText, statusText, xmlhttprequest));

When loading a page, if an error occurs, the corresponding prompt will be displayed based on the status given by statusText, which is very important for users.

Example, load post

The code is as follows

Copy code The code is as follows:

click me

Content loading

$("#btnAjaxPost").click(function(event)
{
var username = $("#username").val();
//Send Post request
$("#divResult").load("$(www.jb51.net){ctx}/jqueryLoad", { "username": username});
});


Example, load get method

The code is as follows

Copy code The code is as follows:

Content loading


Ajax method $.load garbled code

Generally, the reason why the load is garbled is because the encoding of the two pages does not affect it. The solution is

1. The encoding of my display page index.html is uft-8;
2. The encoding of my static page foot.html is uft-8;

$("#index_foot_container").load("foot.html");

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