How jquery loads an HTML page into the div i specify

Source: Internet
Author: User

One, jquery how to load an HTML page into the div i specified. (from Baidu know)I want to load some part of the a.html into a div in b.html.
For example, I'm going to load a.html inside the <div id= "acontent" ></div> this div inside of all content loaded into the b.html div <div id= "Rightcon" ></ Div>
How would you like to write it?

With jquery Ajax can do
Suppose A.html and b.html in the same directory
B.html
<script >
$ (document). Ready (function () {
Bodycontent = $.ajax ({
URL: "B.html",
Global:false,
Type: "POST",
Data: ({
Id:this.getAttribute (' acontent ')
}),
DataType: "HTML",
Async:false,
Success:function (msg) {
Alert (msg);
}
})
});
</script>


Second, Juqery $.ajax request another HTML page designated "part" loaded into this page div, the focus is part of the data loaded into this page div (from Baidu know) to the idea as follows:
$.ajax ({
Url:url,//This is the address of the static page
Type: ' Get ',///static page is used with gets method, otherwise the server throws 405 error
Success:function (data) {
var result = $ (data). Find ("a specified part of another HTML page");
$ ("this page div"). html (result);


}
});


or refer to the following code:
$ (function () {
$.ajax ({
Type: "POST",
URL: "Loginloadarticle.ashx",
Data: "Type=" +escape ("latest announcement"),
Success:function (msg) {
$ (". Gonggao"). HTML (msg);
},
Error:function (XMLHttpRequest, Textstatus, Thrownerror) {}
})

})


If the parameters are not clear you can refer to

three, jquery $.ajax () method parameter detailed http://blog.csdn.net/chelen_jak/article/details/22742567

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.