Advertisement
Guest User

Untitled

a guest
Mar 6th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function(){
  2.     $('#search .dropdown-menu li a').on('click', function(e){
  3.         e.preventDefault();
  4.  
  5.         var $this = $(this),
  6.             thisText = $this.text().trim(),
  7.             changedText = $this.closest('.dropdown-menu')
  8.                                .siblings('.dropdown-toggle')
  9.                                .first();
  10.  
  11.         $('#searchType').val(thisText);
  12.         changedText.text( 'по ' + thisText );
  13.     });
  14.  
  15.     //Функция отпраки данных
  16.     $('#search').on('submit', function(e){
  17.         var selfSer = $(this).serialize();
  18.         e.preventDefault();
  19.  
  20.         $.ajax({
  21.             data : selfSer,
  22.             url : '/test/',
  23.             type : 'GET',
  24.             dataType : 'json',
  25.             statusCode: {
  26.                 400: function() {
  27.                     alert("Bad Request");
  28.                 },
  29.                 500: function() {
  30.                     alert("Internal Server Error");
  31.                 }
  32.             }
  33.         }).done(function(data){
  34.             console.log(data);
  35.         }).fail(function(jqXHR, textStatus){
  36.             console.log('Ошибка запроса: ' + textStatus);
  37.         });
  38.  
  39.         console.log(selfSer);
  40.     });
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement