Faber Estello2016-05-02 19:48:50
Faber Estello, 2016-05-02 19:48:50

Ajax+php contact form without reload for landing page?

That that is

Maybe someone will be able to help to understand the return form for the page.
I don’t know how to correctly design back forms for a simple landing, using only js or using ajax + php?
If with php , then how can all this be implemented correctly so that after clicking on submit, a fancy window appears with a message about successful submission or vice versa about failure! What should be in the php file in this case.

Please do not throw links to Google search, I have already rummaged through everything, but I did not find anything suitable.
In js, php is not very strong. In general, it’s not difficult for anyone, please!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
VZVZ, 2016-05-02

> how to properly design back forms for a simple landing page, using only js or using ajax + php?
PHP is required because without it, it is impossible to send anything to e-mail, much less to the database.
1. Create a PHP script that accepts POST request parameters and returns a response via echo: successful or not (possibly in JSON format).
2. From JS, make a POST request to this script, see xmlhttprequest.ru
3. Next, they process the response of the script with JS, and if it’s successful, then they display the corresponding alert or something, and if not, then they also output something.

Sergey ZSA, 2016-05-02

there is enough information about this. You can also use $.ajax, the principle is about the same and you can read a lot about it. Comments on that page are given, there is nothing more to comment on the js-component.
On the php account - create a file that was previously indicated in the ajax function itself (to which the request will go). In it, you properly process your data as a normal post request. That is, that without ajax that with ajax, php handlers can be identical (of course, if you don’t have a redirect in php).
https://habrahabr.ru/post/14246/ this is on pure js (again, I don’t see the point of adding something here, it makes no sense to throw an entire article into a file)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question