X-Git-Url: http://git.ieval.ro/?p=plack-app-gruntmaster.git;a=blobdiff_plain;f=js%2F90-form.js;h=25a11f771640cdaeaa71bd1df4cc7e72b41731eb;hp=9391087d90e0272fcae69481398e4e16784d7b8a;hb=7093e9ba00cf7727a52a49d34d4df12e4f865dd4;hpb=d5bf9a1d1fc3583bc058a90ce28efeb34819744b diff --git a/js/90-form.js b/js/90-form.js index 9391087..25a11f7 100644 --- a/js/90-form.js +++ b/js/90-form.js @@ -1,22 +1,18 @@ -(function(){ - 'use strict'; - - $( document ).ready(function(){ - $('.jsform').on('click', 'input[type="submit"]', function(e){ - var form_data = new FormData(this.parentElement); - var form = $(this).parent(); - var xhr = new XMLHttpRequest(); - xhr.open(form.attr('method'), form.attr('action')); - xhr.onload = function() { - $('#result').html(this.responseText); - }; - xhr.onerror = function() { - $('#result').html('Error!'); - }; - window.scrollTo(0, 0); - $('#result').html('Loading...'); - xhr.send(form_data); - return false; - }); +$(function(){ + $('.jsform > input[type="submit"]').on('click', function(e){ + var form_data = new FormData(this.parentElement); + var form = this.parentNode; + var xhr = new XMLHttpRequest(); + xhr.open(form.getAttribute('method'), form.getAttribute('action')); + xhr.onload = function() { + $('#result')[0].innerHTML = this.responseText; + }; + xhr.onerror = function() { + $('#result')[0].innerHTML = 'Error!'; + }; + window.scrollTo(0, 0); + $('#result')[0].innerHTML = 'Loading...'; + xhr.send(form_data); + e.preventDefault(); }); -})(); +});