Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $( document ).ready(function() {
- $("#btn").click(
- function(){
- sendAjaxForm('result_form', 'reg_form', 'index.php/registration/');
- return false;
- }
- );
- });
- function sendAjaxForm(result_form, ajax_form, url) {
- jQuery.ajax({
- url: url, //url страницы (action_ajax_form.php)
- type: "POST", //метод отправки
- dataType: "html", //формат данных
- data: jQuery("#"+ajax_form).serialize(), // Сеарилизуем объект
- success: function(response) { //Данные отправлены успешно
- result = jQuery.parseJSON(response);
- document.getElementById(result_form).innerHTML = "<b>пп"+result.naz+"</b><hr>"+result.mes;
- },
- error: function(response) { // Данные не отправлены
- document.getElementById(result_form).innerHTML = "Ошибка. Данные не отправлены.";
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement