user570782
user570782

Reputation: 116

how to pass a "a href click" into jquery

i am trying to put a pagination page into jquery. example.html?id=foo&get=23

i would like to pass the get= into the jquery script so that i can change the page within the div instead of sending the link to the having the user see example.html?id=foo&get=23, they should only see example.html?id=foo. the rest is done in jquery.

<script >
$(document).ready(function()
 {
 $("#data").load("page.php?ht=<?php print $id; ?>&p=1"  );
 $("#next").click(function(){
  var pageNum = this.id;
  $("#content").load("page.php?ht=<?php print $id; ?>&p=" + pageNum, Hide_Load());
 });
});

<div id="data"> 
    <a href="example.html?id=foo" id="next">page1</a> 

</div> 

Upvotes: 1

Views: 834

Answers (4)

wargodz009
wargodz009

Reputation: 305

you need something like this:

$(document).ready(function(){
  $("#next").click(function(){
      $.post('your_script_to_get_values.php',
         { page: "1" },
         function(data) {
         $('#content').html(data);
       });
     });
  });  

Upvotes: 1

bozdoz
bozdoz

Reputation: 12860

Make sure you use a live click handler, and not just a click handler, because you are creating the #next element after the page loads.

$("#next").live('click', function(){  //etc.

Documentation for .live()

It matches the current selector now and in the future (i.e. if the elements are created dynamically).

Upvotes: 1

Zaldy Baguinon
Zaldy Baguinon

Reputation: 96

Why not modify the anchor

$('#next').attr("href","example.html?id=45");

After every click on the page?

Upvotes: 2

Vincent Agnello
Vincent Agnello

Reputation: 475

The simplest way would be with a session variable.

Upvotes: 0

Related Questions