Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. $( document ).ready(function() {
  2.         $("#btn").click(
  3.             function(){
  4.                 sendAjaxForm('result_form', 'reg_form', 'index.php/registration/');
  5.                 return false;
  6.             }
  7.         );
  8.     });
  9.  
  10.     function sendAjaxForm(result_form, ajax_form, url) {
  11.         jQuery.ajax({
  12.             url:     url, //url страницы (action_ajax_form.php)
  13.             type:     "POST", //метод отправки
  14.             dataType: "html", //формат данных
  15.             data: jQuery("#"+ajax_form).serialize(),  // Сеарилизуем объект
  16.             success: function(response) { //Данные отправлены успешно
  17.                 result = jQuery.parseJSON(response);
  18.                 document.getElementById(result_form).innerHTML = "<b>пп"+result.naz+"</b><hr>"+result.mes;
  19.             },
  20.             error: function(response) { // Данные не отправлены
  21.                 document.getElementById(result_form).innerHTML = "Ошибка. Данные не отправлены.";
  22.             }
  23.         });
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement