Home>

There is the following code:

$.ajax
({
    type: 'POST',
    url: 'test.php',
    data: option.stopImageNumber,
    success:function(data)
    {
        alert(option.stopImageNumber);
    }
})

The 'option.stopImageNumber' variable generates a random number each time. When this script is executed, the output from this variable is successfully displayed in 'alert(option.stopImageNumber);', but it cannot be retrieved by PHP. Please help to get number from this variable in PHP.

@Vadim.. data: { 'data': option.stopImageNumber }

sousage12122022-01-15 13:04:18

How can you indicate this?

Вадим2022-01-15 11:41:37

because in the ajax request you didn't specify that option.stopImageNumber should be passed under the data key. Accordingly, in php you get this error

ArchDemon2022-01-15 11:29:48

$option= $_POST['data']; When using this code, an error appears: Warning: Undefined array key "data" in

Вадим2022-01-15 11:27:09

Something is not visible in php code

ArchDemon2022-01-15 11:09:45