How to use the data handler after Ajax request?

Trying to deal with Ajax, please do not swear ))
Want to understand how to use data from the processor and what is it all about?

There is such task: there is a registration form on the page "Test", I click the register button and the data sent to the Ajax handler test.php where randomly generated n-number and sent to the telephone indicated in the registration form.

$.ajax({
 url: "test.php",
 success: function(data){
 Appears a modal window;
}
});


File test.php:
<?
$chislo = random number;
sent to the phone
?>


1) How to understand what returns the handler?
2)is it Possible that variable $chislo after you submit your use on this page? (in a modal window the person will enter the number from the SMS message and need to compare this variable with $chislo.)

Please do not swear, I want to understand the basics! In particular, the term "processor returns the data, what data, where returns like take off go back to work?"

Maybe I'm wrong doing this task, then correct
June 8th 19 at 16:37
1 answer
June 8th 19 at 16:39
The question is difficult to explain without knowledge of theory.
I recommend to implement this script without JS, and then when he's ready .php, implement ajax

1. To understand what returns the file .php need to see his code. It would be nice if you put it here. Frequently used functions for debugging: var_dump, print_r (type them in Google and you will see a link to php.net)
2. Of course, you can save it in a variety of ways, here are some of them: placing them in the address bar, maintaining cookies, saving the session, saving to a text file, saving into the database

Choose on taste :)

Links
php.net/manual/ru/features.cookies.php
php.net/manual/ru/session.examples.basic.php
php.net/manual/ru/function.file-put-contents.php
php.net/manual/ru/book.mysql.php
Yes - alexys_Pouros commented on June 8th 19 at 16:51
I recommend to implement this script without JS, and then when he's ready .php, implement ajax


Without JS? Maybe I do not understand something, but how to get form data? And about the php file I vkratse described, i.e. there is especially nothing to watch ) the variable into which the number is generated, which is then sent through stronie api, everything. I think there is code sending is not mandatory, the main thing is the number in a variable, here I am and it must - antonina_Aufderhar87 commented on June 8th 19 at 16:42
if I understand correctly, try to write "echo $chislo;" and then in the Ajax data variable you will see the response from the server(but echo is not the only way to send a response) - alexys_Pouros commented on June 8th 19 at 16:45
So ) ie, in the handler, write "echo $chislo;" and on the page (layout) to use variable data? Understood correctly? - antonina_Aufderhar87 commented on June 8th 19 at 16:48

Find more questions by tags JavaScriptjQueryPHP