Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery ajax php: page content not refrshing!
    primarykey
    data
    text
    <p>i am trying to implement pagination. A set of 9 products are displayed at a time. then upon clicking on a "View More" button, the content of a div should refresh by AJAX and show the next set of 9 products..here's the php code</p> <pre><code>if(!isset($_SESSION['current'])){ $query = "SELECT MAX(addedon) AS addedon FROM tags"; $result = mysql_query($query); report($result); $dated = mysql_fetch_assoc($result); $recent = $dated['addedon']; $_SESSION['current'] = $recent; } $query = "SELECT id, addedon FROM tags WHERE addedon &lt;= '{$_SESSION['current']}' ORDER BY addedon DESC LIMIT 9 "; $result = mysql_query($query); report($result); while($row = mysql_fetch_assoc($result)){ $_SESSION['current'] = $row['addedon']; $id = $row['id']; $query = "SELECT name, image, cost FROM tags, stock WHERE tags.id={$id} AND stock.tagid = tags.id "; $result1 = mysql_query($query); report($result1); $prodInfo = mysql_fetch_assoc($result1); $pname = $prodInfo['name']; $pimg = $prodInfo['image']; //the path to the actual image $pcost = $prodInfo['cost']; echo "&lt;div class=\"oneproduct\"&gt;"; echo "&lt;h3&gt;{$pname}&lt;/h3&gt;&lt;br /&gt;"; echo "&lt;img src=\"{$pimg}\" height=\"{$ht}\" width=\"85px\" alt=\"prodImg\" /&gt;&lt;br /&gt;"; echo "&lt;span&gt;Rs. {$pcost}&lt;/span&gt;"; echo "&lt;input type=\"image\" src=\"images/addcart.png\" class=\"addBtn\" /&gt;"; echo "&lt;/div&gt;"; } </code></pre> <p>after all the products would be fetched and displayed, the last product on the page is stored as 'current' variable of SESSION. problem is: the ajax thing always returns the initial set of 9 products and as soon as i refresh the page, the next set of products are coming..how do i make my link change the content?</p> <p>The ajax code:</p> <pre><code>$("#viewMore").bind('click', function(){ $.ajax({ url:'showNineProds.php', type:'POST', dataType:'html', success:function(data){ $("div#nineproducts").html(data); }, error:function(xhr, status){ alert("Problem"); }, complete:function(xhr, status){ } }); }); </code></pre> <p>showNineProds.php simply calls a function that has been written above..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload