после того как удачано отправили форму, выскакивает сообщение "спасибо" и если закрыть сообщение и опять вызвать форму не обновляя страницу, то формы не будет, а только сообщение "спасибо" .
Так вот вопрос, как вызвать по новой форму, не обновляя страницу.
код js:
CODE (javascript):
скопировать код в буфер обмена
скопировать код в буфер обмена
- $(document).ready(function() {
- //if submit button is clicked
- $('#form').submit(function () {
- //Get the data from all the fields
- var name = $('input[name=name]');
- var email = $('input[name=email]');
- var tel = $('input[name=tel]');
- //Simple validation to make sure user entered something
- //If error found, add hightlight class to the text field
- if (name.val()=='') {
- name.addClass('hightlight');
- return false;
- } else name.removeClass('hightlight');
- if (email.val()=='') {
- email.addClass('hightlight');
- return false;
- } else email.removeClass('hightlight');
- if (tel.val()=='') {
- tel.addClass('hightlight');
- return false;
- } else tel.removeClass('hightlight');
- //organize the data properly
- var data = 'name=' + name.val() + '&email=' + email.val() + '&tel=' +
- tel.val();
- //disabled all the text fields
- //show the loading sign
- $('.loading').show();
- //start the ajax
- $.ajax({
- //this is the php file that processes the data and send mail
- url: "process.php",
- //GET method is used
- type: "GET",
- //pass the data
- data: data,
- //Do not cache the page
- cache: false,
- //success
- success: function (html) {
- //if process.php returned 1/true (send mail success)
- if (html==1) {
- //hide the form
- //show the success message
- $('.blk-data .form1').fadeOut('slow');
- $('.loading').fadeOut('slow');
- $('.done').fadeIn('slow');
- //if process.php returned 0/false (send mail failed)
- } else alert('Sorry, unexpected error. Please try again later.');
- }
- });
- //cancel the submit button default behaviours
- return false;
- });
- });