View file 2/3020.ru/system/AJAX/change/touch/form.js

File size: 989B
/*
------------------
AJAX загрузка форм
------------------
*/

$(document).on('click', '.ajax-button', function(e){
  
  var $that = $('.form');
  var link = $that.attr('action');
  
  $('.ajax-button').html('<i class="fa fa-spinner fa-spin fa-fw"></i> Ждите...');
  
  $('#load').html('<div class="animate-load stripes-load" style="width: 100%; position: absolute; top: 0; left: 0; right: 0;"><div class="proccess-load"></div></div>');
  
  $.post(
    
    link,
    
    $that.serialize(),
    
    function(data) { 
      
      var title_ajax = $('div[title]').text();
      document.title = title_ajax;
      history.pushState(link, title_ajax, link);
      
      open_modal = 0;
      
      document.body.scrollTop = 0;
      document.documentElement.scrollTop = 0;
      
      var data = $(data);
      var elem = data.find('#content').html();
      $("#content").html(elem);
      
      $('#load').html('');
    
    }
  
  );
  
  e.preventDefault();
  
});