简体   繁体   English

PHP Jquery Ajax-获取网址参数

[英]PHP Jquery Ajax - Get Url Param

I am working on an Ajax Login form. 我正在使用Ajax登录表单。 On the PHP processing page when the login is successful, there are 3 options to redirect the user. 登录成功后,在PHP处理页面上,有3个重定向用户的选项。

<?php
// ------------------------------------------------------------
// PROCESS LOGIN FORM ON POSTBACK
// ------------------------------------------------------------

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    ...

    // 1. DEFAULT URL: default destination url from config
    $plLoginDestinationUrl = PL_DEFAULT_LOGIN_DESTINATION;

    // 2. RETURN URL: if return address present in url
    if (isset($_GET['ReturnUrl'])) {
        $plLoginDestinationUrl = $_GET['ReturnUrl'];
    }

    // 3. PER USER URL: if custom user destination in db exists
    if ($pllogin->loginDestinationUrl != 'default') {
        $plLoginDestinationUrl = $pllogin->loginDestinationUrl;
    }
}

If the form is submitted without javascript (jquery), everything works fine. 如果提交的表单没有使用JavaScript(jquery),则一切正常。 Submitting the page with ajax fails on #2. 使用Ajax提交页面在#2上失败。 It just won't parse the $_GET['ReturnUrl']. 它只是不会解析$ _GET ['ReturnUrl']。

The PHP error response I always get when submitting with ajax is: Notice: Undefined index: ReturnUrl in. 使用ajax提交时,我总是得到的PHP错误响应是:注意:未定义的索引:ReturnUrl输入。

Ajax is most likely POSTing not GETing. Ajax很可能是POST而不是GETING。 Try and replace $_GET['ReturnUrl']; 尝试并替换$_GET['ReturnUrl']; to $_POST['ReturnUrl']; $_POST['ReturnUrl']; or even $_REQUEST['ReturnUrl']; 甚至$_REQUEST['ReturnUrl'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM