I have two pages. One page contains a form that will direct to a search results page when the user presses submit. The other page is the search results page. When the user hits submit, the URL of the search results page will say something like "www.theURL.com?pg=-thepagenum-". Afterwards, results will display and at the bottom will be a link saying display next x amount of pages and each page URL will have the "pg" portion incremented by 1. To do this, I thought of using a synchronous ajax post that will post to the search results page again.
Starting from the form page, I click submit and it loads the search results page populated with my results. However, when I click for the next page of results, I receive multiple php errors saying my $_POST variables are undefined. Is my logic in achieving my end result wrong? The success callback works but when it goes to that page, nothing is displayed but the php errors.
//Display next page of results
$("#next_results").click(function(){
$.ajax({
type: 'POST',
url: "search_results.php?pg=<?php echo ++$_REQUEST['pg'] ?>&UI=<?php echo $_REQUEST['UI'] ?>",
<?php if(isset($_POST['keyword_search'])) { //Post info for keyword search ?>
data: {keyword_search: 'true',
keywords: <?php echo $_POST["keywords"]; ?> },
<?php } //End if posting for keyword search
else { //Post info for basic quick search ?>
data: {'MOsearch_my_gender': gender_string ,
min_age: <?php echo $_POST["min_age"]; ?> ,
max_age: <?php echo $_POST["max_age"]; ?> ,
MOsearch_my_orientation: orientation_string ,
state_country: location_string ,
only_zip: '<?php echo $_POST["only_zip"]; ?>' ,
orderby: '<?php echo $_POST["orderby"]; ?>' ,
logged_last_months: <?php echo $_POST["logged_last_months"]; ?> ,
only_photos: pictures_only ,
only_premium: premium_only ,
only_online: online_only ,
ChosenResultsPerPage: <?php echo $_POST["ChosenResultsPerPage"]; ?> },
<?php } //End if posting for basic quick search ?>
success: function () {alert("success")},
async:false
});
});
});