Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用jQuery加载内容?_Php_Jquery_Class_Pagination - Fatal编程技术网

Php 如何使用jQuery加载内容?

Php 如何使用jQuery加载内容?,php,jquery,class,pagination,Php,Jquery,Class,Pagination,我正在尝试将ajax功能添加到分页中,以便在同一页面中加载内容,而不是用户在单击页面链接时必须导航到另一页面 我应该提到我正在使用 作为jquery的新手,我不确定如何正确地使用分页类实现这一点 这是主页的外观: <?php $categoryId=$_GET['category']; echo $categoryId; ?> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jq

我正在尝试将ajax功能添加到分页中,以便在同一页面中加载内容,而不是用户在单击页面链接时必须导航到另一页面

我应该提到我正在使用

作为jquery的新手,我不确定如何正确地使用分页类实现这一点

这是主页的外观:

<?php
$categoryId=$_GET['category'];
echo $categoryId;
?>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery_page.js"></script>

<?php
    //Include the PS_Pagination class
    include('ps_pagination.php');
    //Connect to mysql db
    $conn = mysql_connect('localhost', 'root', 'root');
    mysql_select_db('ajax_demo',$conn);
    $sql = "select * from explore where category='$categoryId'";
    //Create a PS_Pagination object
    $pager = new PS_Pagination($conn, $sql, 3, 11, 'param1=value1&param2=value2');
    //The paginate() function returns a mysql
    //result set for the current page
    $rs = $pager->paginate();
    //Loop through the result set

echo "<table width='800px'>";

    while($row = mysql_fetch_assoc($rs)) {            

                echo "<tr>";
                    echo"<td>";
                    echo $row['id'];
                    echo"</td>";

                    echo"<td>";
                    echo $row['site_description'];
                    echo"</td>";

                    echo"<td>";
                    echo $row['site_price'];
                    echo"</td>";
                echo "</tr>";

    }
echo "</table>";

        echo "<ul id='pagination'>";

            echo "<li>";
            //Display the navigation
            echo $pager->renderFullNav();
            echo "</li>";

        echo "</ul>";

?>

<div id="loading" ></div>
<div id="content" ></div>

<a href="#" class="category" id="marketing">Marketing</a>

<a href="#" class="category" id="automotive">Automotive</a>

<a href="#" class="category" id="sports">Sports</a>

将加载其中一个
/url/path/marketing、/url/path/automotive或/url/path/sports


进入内容部分

您遇到的具体问题是什么(而不仅仅是“我不确定该怎么办”)?例如,我在这个脚本中没有看到任何ajax调用。那么,这些问题通常与如何设置分页类有关吗?或者如何使用jQuery Ajax?我不确定如何执行jQuery,因此当用户单击例如第2页时,jQuery将加载第2页,而不会将用户发送到另一页。
$("a.category").live("click", showContent)

function showContent()
{
   $("#content").load("/url/path/" + $(this).attr("id"));
}