Why doesn't PHP see POST request for ajax?

  • 0
    There is ajax request:
    $.ajax({
            url: '../index.php',
            type: 'POST',
            data: {
                'auth_code': auth_code,
            },
            success: function(response) {
                alert('успех!')
            },
            error: function(jqXHR, textStatus, errorThrown) {
                console.log(textStatus);
            }
        });

    But PHP doesn't see them:
    if (isset($_POST['auth_code'])){
        echo("Успех");
    }

    The same piece of code worked on another "project", but there is no reaction to the post here.
    AJAX Anonymous, Jun 14, 2020

  • 2 Answers
  • 0
    The same piece of code worked on another "project", but there is no reaction to the post here.


    And what is there? What are you doing in general? what are the errors in the console?

    Are there any errors in the pkhp log?

    On the screen, it looks like this url does not work correctly for you and throws it to the index in the dashboard.
    Anonymous

  • 0
    url: '../index.php' - url cannot be of this kind. You are confusing url and file path
    Adeline Estes

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!