views:

67

answers:

2
<script type="text/javascript" charset="utf-8"> 

 $(document).ready(function() {
    $("a").click(function() {
        $("#myDiv").load( "job_board_data.php", { pageNo: $(this).text()} );
        return false;
    });
});
</script>
<a href="job_board_data.php?p=1">1</a>

How can I pass variables to my job_board_data.php script???? I want to pass variables such as page, sort by .. anyone?

+1  A: 
$(document).ready(function() { 
  $("a").click(function() { 
    $("#myDiv").load("job_board_data.php", { pageNo: $(this).text()} ); 
    return false; 
  }); 
});

In that code, when a user clicks on a link, you are loading the contents of the response for "job_board_data.php?pageNo=1" into a div.

job_board_data.php sees this as a regular HTML url call, so it would put the parameters (that you specified in the second parameter of $.load.

for example, using your above .load statement:

$_POST['pageNo'] 

will return

"1"
JBristow
thats the problem, it does not echo $_GET['pageNo'];its empty
vick
You need `$_POST['pageNo'];` since an object is being passed as opposed to a string. See http://api.jquery.com/load/
karim79
Good point @karim79, updating my example to reflect actual real-world behavior. I've been on the backend too long.
JBristow
A: 
$('a').click(function () {
    $('#myDiv').load($(this).attr('href'));
}
Sasha