Recently, I often notice how when sending a form to third-party sites, the form is sent without going to other pages / scripts.

in other words:

  1. went to the site
  2. entered data
  3. clicked the "send" button
  4. jumped out the informative window "data sent" WITHOUT GO ON DR. PAGES. all actions on one

how to implement it? thank!

  • XMLHttpRequest is done and a message is displayed. - vkovalchuk88
  • one
    It feels like you are 5 years behind) - dlarchikov
  • Yes, I really haven't been doing web development for a hundred years) - jackair

1 answer 1

This is possible with AJAX.

In this example: http://jsfiddle.net/alpha9000/SbxHT/ in the field where JS lines up for the PHP script that will accept the information and send it to the file / mail.

  • Is this code AJAX? It will work on regular servers cat support PHP and only? Or is it a bit like javascript? $ ('# feedback div'). click (function () {$ ('# feedback ul'). toggle (300);}); $ ('# feedback a'). click (function () {var kx = 'name =' + $ ('# feedback input [name = fname]'). val () + '& phone =' + $ ('# feedback input [name = phone] '). val (); // pass in $ _POST to feedback.php $ .ajax ({url:' feedback.php ', type:' POST ', dataType:' html ', data : kx}); $ ('# feedback ul'). toggle (300); return false;}); - jackair
  • Went, jquery and maybe he does not need to connect jquery? - vkovalchuk88
  • jQuery is JavaScript and it runs on the client and not on the server. And any severre with PHP will go. - ferrari
  • So, I did everything, for some reason it does not work ... Here is the code, tell me please, where did you make a mistake? Here's the code index.php did not change anything: unfortunately the number of characters is limited, so here's a photo: gyazo.com/5cde19417c4e932bf88c94796ea17bcb.png But what I changed is feedback.php But it’s working, 100%. it still works on my site, everything is fine gyazo.com/62081888bac4ae278e4bcd0eb5cbfa7d.png what's the error then?) - jackair
  • Wrap the code in: $ (document). Ready (function () {// here is the code from the example}); and check the console, it looks like it works. - ferrari