Loading an HTML page to a specified div using jquery

Source: Internet
Author: User

First, jquery loads an HTML page into the specified div

Load the contents of a part of a.html into a div in b.html.
For example: Loading a.html inside the <div id= "row" ></div> this div inside all the content loaded into b.html this div <div id= "content" ></div>

With jquery Ajax you can achieve
Suppose a.html and b.html are in the same directory
B.html

1<script >2$ (document). Ready (function() {3Bodycontent =$.ajax ({4URL: "B.html",5Globalfalse,6Type: "POST",7 data: ({8Id: This. getattribute (' Row ')9         }),TenDataType: "HTML", OneAsyncfalse, ASuccessfunction(msg) { - alert (msg); -         } the     }) - }); -</script>

Second, Juqery $.ajax request Another HTML page of the specified "part" loaded into this page Div, focus is part of the data loaded into this page div

The big idea is as follows:

1 $.ajax ({2Url:url,//here is the address of the static page3Type: "GET",//static page with Get method, otherwise the server throws a 405 error4Successfunction(data) {5             varresult = $ (data). Find ("a specified part of another HTML page");6$ ("this page div"). HTML (result);7 8 9         }Ten});

or refer to the following code:

1$(function(){2 $.ajax ({3Type: "POST",4URL: "Loginloadarticle.ashx",5Data: "Type=" +escape ("latest announcement") ,6Successfunction(msg) {7$ (". Gonggao"). HTML (msg);8             },9Errorfunction(XMLHttpRequest, Textstatus, Thrownerror) {}Ten         }) One       A})


If the parameter is not clear, refer to

Third, jquery $.ajax () method parameter detailed

http://blog.csdn.net/chelen_jak/article/details/22742567

Loading an HTML page to a specified div using jquery

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.