Answer the question
In order to leave comments, you need to log in
How does this ajax code work?
Hello!
Helped wrote code, forms but I can't understand how it works
// Отправить номер на сервер
sendNumber (number) {
$.ajax({
url: '/path/to/file', // Куда отправить
type: 'default GET (Other values: POST)', // Каким методом
dataType: 'json',
data: {
number
}
})
.done(() => console.log("success"))
.fail(() => console.log("error"));
}
Answer the question
In order to leave comments, you need to log in
When submitting the form, you call the sendNumber function, having previously grabbed the filled
url number: '/path/to/file', - you write the path to the php file of the
type:'POST' handler
in this file
<?
if ($_POST)
{
mail('[email protected]','Subject',$_POST['number']);
echo 'Thank you';
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question