There is this piece of ajax code:

    type: "POST",
    dataType: "text",
    url: "index.php",
    dataType: 'text'
    data: { option: option number },

The 'option.number' variable generates a new number each time. In 'alert' this number is displayed successfully, but in php it doesn't.

I tried to output like this:

    $option= $_POST['option'];
    echo 'Number: '.$option.'';

gives a blank page. Please help, I've been racking my brains for 3 days how to display a variable from ajax in php. Thank you very much in advance!

if there is an alert in it, then the server returns everything. so it's not clear what you mean by "but in php nothing" and "produces a blank page"

Алексей Шиманский2022-01-18 21:57:13

A blank page is displayed in php, there is no this same output from ajax.

wideb925032022-01-18 21:57:13

how can a white page be displayed in PHP if you make a request with ajax on JS?

Алексей Шиманский2022-01-18 21:57:13

"there is no such output from ajax" ---you write "This number is successfully displayed in 'alert'"

Алексей Шиманский2022-01-18 21:57:13

The alert is displayed, but the index.php page is empty.

wideb925032022-01-18 21:57:13