Home >Web Front-end >JS Tutorial >Implementation code for loading other pages in jQuery Div_jquery

Implementation code for loading other pages in jQuery Div_jquery

WBOY
WBOYOriginal
2016-05-16 18:55:31910browse

After many attempts, I finally found a solution that I am quite satisfied with, and now I am writing it in my blog to share with you.
The first step is to provide an area in the sign-off page to display the form content. DIV is used here.

Copy code The code is as follows:


$p = new Portlet();
$p->setCaption("Document View")
- >setShowBorder(false)
->addItem("
") //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 piece of JavaScript to get the form page, using jQuery
Copy the code The code is as follows:

//Dynamic loading page
//id Container component ID of the displayed page
//url URL of the page to be loaded
function loadPage(id, url) {
$ ("#" id).addClass("loader");
$("#" id).append("Loading...");
$.ajax({
type : "get",
url: url,
cache: false,
error: function() {alert('Error loading page 'url '!');},
success: function (msg) {
$("#" id).empty().append(msg);
$("#" id).removeClass("loader");
}
} );
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn