[英]jQuery load() and pass to php GET and get data from #div
I want to send request to PHP file, ie. 我想发送请求到PHP文件,即。 ?page=1 and get the data from #div from the same php file, and do all using jquery .load();
?page = 1并从同一php文件中从#div获取数据,并全部使用jquery .load();来完成。
I'm trying to do this like that: 我正在尝试这样做:
$('#content_text').load("page1.php?page=1" + " #page1_tit");
And it doesn't work. 而且它不起作用。 I get no data inside #content_text and I have no errors in the console.
我在#content_text中没有任何数据,并且控制台中没有错误。 Look's like ?page=1 request doesn't work.
看起来像第1页的请求无效。 Anyone knows how to do that ?
有人知道该怎么做吗?
This is the page1.php 这是page1.php
<?PHP
if (isset($_GET['page'])) {
$i = $_GET['page'];
print $i;
include 'db.php';
if ($db_found) {
$SQL1 = "SELECT ID, content, tittle FROM pages WHERE ID = '$i'";
$result = mysql_query($SQL1);
while ( $db_field = mysql_fetch_assoc($result) ) {
print "<div id=\"#page1_tit\">";
print $db_field['tittle'];
print "</div>";
print "<div id=\"#page1_cont\">";
print $db_field['content'];
print "</div>";
}
mysql_close($db_handle);
}
print $i;
}
?>
看起来您的变量$ db_found ist为false或数据库查询返回0行,因此while不会运行。
<input type="button" id="pageloader" name="pageload">
<script type="text/javascript">
$(document).ready(function(){
$("#pageloader").click(function(){
$('#content_text').load("page1.php?page=1" + " #page1_tit");
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.