Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 16:33:21
Original
1425 people have browsed it

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");

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