Home>
There is this piece of ajax code:
$.ajax
({
type: "POST",
dataType: "text",
url: "index.php",
dataType: 'text'
data: { option: option number },
success:function(data)
{
alert(data);
}
})
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:
if(isset($_POST['option']))
{
$option= $_POST['option'];
echo 'Number: '.$option.'';
exit();
}
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!
A blank page is displayed in php, there is no this same output from ajax.
wideb925032022-01-18 21:57:13how 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:13The alert is displayed, but the index.php page is empty.
wideb925032022-01-18 21:57:13Related questions
- javascript : How can I transfer Recaptcha v2 for solution to another person
- javascript : Passing variable from ajax to php not working
- javascript : Help with routine please
- javascript : js code execution protection
- javascript : How to delete a row from a database table using Ajax, without reloading the page?
- javascript : How to restrict adding users
- javascript : How to send file to PHP server from JS?
- javascript : How to implement a limit on the number of adding customers to the site
- javascript : Is it a sin to use situational (==) instead of (===) and Function Declaration instead of Expression
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