Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function submit_form(e) {
- var $form = $(e.target),
- $btn = $form.find('button'),
- btn_text = $btn.text();
- $.ajax({
- // url: '/',
- data: $form.serialize(),
- dataType: 'json',
- type: 'POST',
- beforeSend: function() {
- $('#contact_fail .alert-inner').empty();
- $('#contact_fail').hide();
- $btn.attr('disabled', 'disabled').addClass('btn-disabled').css('cursor', 'not-allowed').text('Отправляется...');
- },
- success: function(result) {
- if (typeof result.success == 'undefined') {
- // form is not valid, display errors
- for (var x in result) {
- $('#contact_fail .alert-inner').append('<p>' + result[x] + '</p>');
- }
- $('#contact_fail').fadeIn();
- }
- else {
- // form sent successfully and without errors
- $('#contact_success').fadeIn(700, function() {
- var $this = $(this);
- setTimeout(function() {
- $this.fadeOut();
- }, 5000);
- });
- }
- },
- complete: function() {
- $btn.removeAttr('disabled', 'disabled').removeClass('btn-disabled').css('display', 'none').html(btn_text);
- },
- error: function(jqXHR, textStatus, errorThrown) {
- switch (jqXHR.status) {
- case 404:
- alert("Мы сожалеем... Файл который вы ищете не найден :(");
- break;
- case 200, 500:
- $('#contact_fail .alert-inner').append("<p>Ой ой, что то пошло не так, и мы не можем отправить ваше сообщение :(</p>");
- $('#contact_fail').fadeIn();
- console.log(jqXHR, textStatus, errorThrown);
- break;
- default:
- console.log(jqXHR, textStatus, errorThrown);
- }
- }
- });
- }
- <?php
- if (Core::moduleIsActive('form'))
- {
- ob_start();
- $oForm = Core_Entity::factory('Form', '21');
- $Form_Controller_Show = new Form_Controller_Show($oForm);
- $Form_Controller_Show
- ->values($_POST + $_FILES)
- // 0 - html, 1- plain text
- ->mailType(0)
- ->mailXsl(
- Core_Entity::factory('Xsl')->getByName('ПисьмоКураторуФормыВФорматеHTML')
- )
- ->mailFromFieldName('***@car-carych.ru')
- ->process();
- $data = ob_get_clean();
- $Form_Controller_Show
- ->xsl(
- Core_Entity::factory('Xsl')->getByName('ОтобразитьФормуНаГлавной')
- )
- ->show();
- echo json_encode( $data );
- }
- ?>
- <?php
- if (Core::moduleIsActive('form'))
- {
- ob_end_clean();
- ob_start();
- $oForm = Core_Entity::factory('Form', '21');
- $Form_Controller_Show = new Form_Controller_Show($oForm);
- $Form_Controller_Show
- ->values($_POST + $_FILES)
- // 0 - html, 1- plain text
- ->mailType(0)
- ->mailXsl(
- Core_Entity::factory('Xsl')->getByName('ПисьмоКураторуФормыВФорматеHTML')
- )
- ->mailFromFieldName('***@car-carych.ru')
- ->process();
- $Form_Controller_Show
- ->xsl(
- Core_Entity::factory('Xsl')->getByName('ОтобразитьФормуНаГлавной')
- )
- ->show();
- $data = ob_get_clean();
- echo json_encode( $data );
- die();
- }
- ?>
Add Comment
Please, Sign In to add comment