Loading a page using jQuery
I am using jQuery
. My main page is index.php
. on load of this page. How do i load another page internally. say a small block i开发者_运维知识库n the page ?
Like this: $('.smallBlock').load('targetUnderSameDomain.php .anotherSmallBlock');
In the first part you select the block where you want to insert the block of the targeted file. The load function has two parts: The first part is where you select the targeted file, the second is optional, but there you can select an element within the targeted file's html.
you can use the load command. For a simple page like this:
<html>
<head>
<title>test</title
</head>
<body>
<div id="content"> </div>
</body>
</html>
you could fill the Div with id = content like this:
$('#content').load('yourUrl.php');
EDIT: changed from get() to load()
the syntax for the get command would be:
$.get('yourUrl.php', function(data){
$('#content').html(data);
});
精彩评论