dousui6488 2015-07-30 19:43 采纳率: 100%
浏览 28

从同步ajax帖子中检索数据

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
        });
        });
    });
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何将下列的“无限压缩存储器”设计出来
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭