Implementation Code for loading other pages in jQuery Div

Source: Internet
Author: User

After a review, I finally found a solution that I was quite satisfied with. I will share it with you in my blog.
The first step is to provide an area on the signature page to display the Form Content, where the DIV is used.
Copy codeThe Code is as follows:
<Script type = "text/javascript">
$ (Document). ready (function (){
LoadPage ("doc_view", "<? Php echo $ this-> doc_view_url. '/flag/1';?> ");
});
</Script>
<? Php
$ P = new Portlet ();
$ P-> setCaption ("Document View ")
-> SetShowBorder (false)
-> AddItem ("<div id = 'doc _ view'> </div>") // This DIv is the container used to display the form content.
-> Render ();
Echo $ this-> partial ("approval/CommentsList. phtml", array ("approval_list" =>$ this-> approval_list ));
?>

The second step is to write a JavaScript code to obtain the form page, using jQuery
Copy codeThe Code is as follows:
// Dynamically load the page
// Id Display the container component ID on the page
// Url
Function loadPage (id, url ){
$ ("#" + Id). addClass ("loader ");
$ ("#" + Id). append ("Loading ......");
$. Ajax ({
Type: "get ",
Url: url,
Cache: false,
Error: function () {alert ('Load page' + url + 'error! ');},
Success: function (msg ){
$ ("#" + Id). empty (). append (msg );
$ ("#" + Id). removeClass ("loader ");
}
});
}

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.