Using jquery to load HTML pages into the specified div implementation _jquery

Source: Internet
Author: User

One, jquery load an HTML page into the specified div

Load the contents of a part of the a.html into a div in b.html.

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

With jquery Ajax you can implement

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 (' Row ')
    }),
    dataType: "html",
    async: False,
    success:function (msg) {
      alert (msg);}})
;
</script>

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

Large to the following ideas:

$.ajax ({
    url:url,//This is the address type of the static page
    : "Get",///static page with Get method, otherwise the server will throw 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 explanation and application

This article uses jquery to load HTML pages to the specified div implementation method is small set to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.

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.