我正在使用PHP和Jquery以及AJAX,正在将数组发布到php会话

时间:2017-02-14 21:38:25

标签: javascript php jquery ajax

我试图用它发布一个数组,但由于一些奇怪的原因,唯一完全初始化的是第三和第零点。

这是我正在使用的JS文件。

<script type="text/javascript">
    jq("#runTour").click(function(e) {
        //e.preventDefault();
        console.log('true set');
        jq.post(window.location.href + '?event=checkTour',{'initialSet[]': [12, 1, '100', window.location.origin + '/ppwweb/control.php/admin/users', window.location.href, '', true] } )
        .done(function(data){
            return jq(".smallipopTour1").smallipop('tour', 0, 12, 'https://devml.propertypreswizard.com/ppwweb/control.php/admin/users');/*'tour' is a keywor needed, the 0 is the current sstep we are on, 12 is the total steps in the tour, annd the address is for when the tour goes to a new page */ 
        });

    });
    function continueTour1(e) {
    //e.preventDefault()

    return jq('.smallipopTour1').smallipop('tour', 0, 12, "https://devml.propertypreswizard.com/ppwweb/control.php/admin/users", "");
  };
          /* Tour stuff */
    jq('.smallipopTour1').smallipop({
    theme: 'white fat-shadow',
    tourTitle: 'Sample',
    preferredPosition: 'right',
    tourHighlight: false,
    popupOffset: 0,
    triggerOnClick: true
    });

这是我要发布的PHP代码。

function checkTourRun (){
    //['on_tour'][0total steps, 1current step, 2steps done, 3Nurl, 4Curl, 5Burl, 6ontour]

    //if(isset($_GET['requested'])) MAYBE
    ob_clean();
    echo '',
        '<pre>';
    print_r($_POST['info']);
    echo '</pre>',
        '';
     if(isset($_POST['initialSet']))
        $_SESSION['on_tour'] = $_POST['initialSet'];

    //echo  'helicopter';
    $pageURL .= 'http';
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
        $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }

    $_SESSION['on_tour'][6] = $_POST['onTourS'];


    if ($_SESSION['on_tour'][6]) {
        $_SESSION['masterCnt'] = $_POST['masterCntS'];//sets master count               
        $_SESSION['on_tour'][4] = $_POST['Curl'];//sets new Current Url
        $_SESSION['on_tour'][5] = $_POST['Burl'];//sets Back Url
        $_SESSION['on_tour'][2] = $_POST['stepsDone'];//sets the # of steps done
        //$thing = $_SESSION['on_tour'][4];


        if ($_SESSION['on_tour'][4] . "?event=checkTour" === $pageURL) {            
            echo false . '\n';
            echo $_SESSION['on_tour'][1] . '\n';
            echo $pageURL;

        }
        else if($_SESSION['on_tour'][1] === $_SESSION['on_tour'][2]){

            echo true;
        }

    }
    echo $_SESSION['on_tour'][0] . '   ';//suppose to be 12
    echo $_SESSION['on_tour'][1] . '   ';//suppose to be 1
    echo $_SESSION['on_tour'][4] . '   ';//suppose to be an url

    //echo $pageURL;
    error_log(print_r('SUPPORT', true), 0);
    error_log(print_r($_SESSION, true), 0);
    //echo $_SESSION['on_tour'][1][6];
    exit;
  }
}

我的问题是,最后几行回显出第0个元素,第3个元素是唯一显示正确项目的行,我不知道为什么。我在我的智慧结束,我真的需要帮助,非常感谢先进。

0 个答案:

没有答案