0
我一直在研究过去两天,并没有发现任何东西。如何从加载div加载sql /会话内容到一个div
结构:
的index.php:
<head>
<script type="text/javascript" src="JS/jquery-1.6.2.js"></script>
<script type="text/javascript" src="function.js"></script>
</head>
<body>
<div>
<div><a href="" class="testcat" id="1">Show</a></div> *-->if I click this link data loads into DIV below by function.js without reloading*
<div id="producten"></div> *-->testpage.php loads here perfect,
the code of testpage.php makes by while loop other links.
Here I want to click on a link to load next data in div id=information
without reloading the index.php so the data in the first DIV stay visible
and I dont know how to do that*
<div id="information"></div> *-->testpage2.php have to load data from sql in this DIV*
</div>
</body>
function.js:
$(document).ready(function() {
$(".testcat").click(function() {
var testid = $(this).attr("id");
var datastring = 'id='+ testid ;
$.ajax({
type: "POST",
url: "testpage.php",
data: datastring,
cache: false,
success: function(res) {
$('#producten').html("<div class='loading'><img src='IMG/loading.gif' /></div>")
.hide()
.fadeIn(2000, function() {
$('#producten').html(res);
})
}
});
return false;
});
});
testpage.php和testpage2.php是用于SQL数据PDO代码。
这是一个有点很难理解你想要什么。你能否显示'testpage.php'和'testpage2.php'的完整代码,并指定在哪个第二个div中加载信息? – 2011-12-17 15:54:06
如果我理解正确,那么您正在关注一个AJAX解决方案。 – 2011-12-17 18:07:22