1
<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?

0

2 Answers 2

1
$(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"
Sign up to request clarification or add additional context in comments.

3 Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.