In jquery, the page Ajax method $. load function, jquery. load

Source: Internet
Author: User

In jquery, the page Ajax method $. load function, jquery. load

Load syntax

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

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

For example, load post

The Code is as follows:
<Div id = btnAjaxPost> click me </div>
<Div id = divResult> loading content </div>

$ ("# BtnAjaxPost"). click (function (event)
{
Var username = $ ("# username"). val ();
// Send a Post request
$ ("# DivResult"). load ("$ (www.111cn.net) {ctx}/jqueryLoad", {"username": username });
});

Example: load get Method

The Code is as follows:
<Div id = in_head> loading content

<Script language = "javascript"> $ ('# in_head'). load ('ajaxlogin. php? Cityid = 1208 '); </script>

Ajax method $. load garbled

Generally, the load garbled characters are caused by the two page codes. The processing method is

1.my display page index.html encoding is a uft-8;
2.my Static Page foot.html code is a uft-8;

$ ("# Index_foot_container"). load ("foot.html ");
From: http://www.111cn.net/wy/jquery/67792.htm


The load () method of jquery ajax cannot obtain page content

I won't talk about the answer upstairs. I'll just say that your IE is ineffective.

In ie, the load () method gets the cached data instead of the server.
Add this js sentence at the beginning of the script so that ie does not read the cache. If it is only a method that uses load (), add this sentence before load () without the need for global settings.
$. AjaxSetup ({cache: false });

I don't understand. Please ask. If it is helpful, remember to adopt it ~

How does jquery ajax submit data in the load () Incoming "page" and return results without refreshing?

Use ajax requests in your load () method.
$. Ajax ({
Type: "POST ",
DataType: "json ",
Url: "Request Path ",
Data: "parameter ",
Success: function (result ){
If (result ){
// Result returned by the request
}
}
});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.