Dimitris Kougioumtzis Blog About technology

Ajax jquery

Category jquery

Posted on July 15, 2017



Ajax jquery


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function($){
    $(document).ready(function(){
      $('#id_form').on('submit', function(e){
          e.preventDefault();
          $.ajax({
              url: $(this).attr('action'),
              method: $(this).attr('method'),
              data: $(this).serialize(),
              datatype: 'json',
              success: function(response){
                $('.result').html('');
                var data = eval(response);
                for (var key in data) {
                  if (data.hasOwnProperty(key)) { // this will check if key is owned by data object and not by any of it's ancestors
                    $('.result').append(key + ':' + data[key] + '</br>'); // this will show each key with it's value
                  }
                }
               }
         });
      });
    });
})(jQuery)

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere