SHARE
TWEET

Untitled

a guest Aug 25th, 2019 234 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * jQuery serializeObject
  3.  * @copyright 2014, macek <paulmacek@gmail.com>
  4.  * @link https://github.com/macek/jquery-serialize-object
  5.  * @license BSD
  6.  * @version 2.5.0
  7.  */
  8. !function(e,i){if("function"==typeof define&&define.amd)define(["exports","jquery"],function(e,r){return i(e,r)});else if("undefined"!=typeof exports){var r=require("jquery");i(exports,r)}else i(e,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,i){function r(e,r){function n(e,i,r){return e[i]=r,e}function a(e,i){for(var r,a=e.match(t.key);void 0!==(r=a.pop());)if(t.push.test(r)){var u=s(e.replace(/\[\]$/,""));i=n([],u,i)}else t.fixed.test(r)?i=n([],r,i):t.named.test(r)&&(i=n({},r,i));return i}function s(e){return void 0===h[e]&&(h[e]=0),h[e]++}function u(e){switch(i('[name="'+e.name+'"]',r).attr("type")){case"checkbox":return"on"===e.value?!0:e.value;default:return e.value}}function f(i){if(!t.validate.test(i.name))return this;var r=a(i.name,u(i));return l=e.extend(!0,l,r),this}function d(i){if(!e.isArray(i))throw new Error("formSerializer.addPairs expects an Array");for(var r=0,t=i.length;t>r;r++)this.addPair(i[r]);return this}function o(){return l}function c(){return JSON.stringify(o())}var l={},h={};this.addPair=f,this.addPairs=d,this.serialize=o,this.serializeJSON=c}var t={validate:/^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,key:/[a-z0-9_]+|(?=\[\])/gi,push:/^$/,fixed:/^\d+$/,named:/^[a-z0-9_]+$/i};return r.patterns=t,r.serializeObject=function(){return new r(i,this).addPairs(this.serializeArray()).serialize()},r.serializeJSON=function(){return new r(i,this).addPairs(this.serializeArray()).serializeJSON()},"undefined"!=typeof i.fn&&(i.fn.serializeObject=r.serializeObject,i.fn.serializeJSON=r.serializeJSON),e.FormSerializer=r,r});
  9.  
  10.  
  11.  
  12. var $form = $('form#test-form'),
  13.     url = 'https://script.google.com/macros/s/AKfycbyEr2sy9bXgzi90ndLl_Y1KKlq0pj7OVv9Q-qwX0uaEkbptnFU/exec';
  14.  
  15. function(e) {
  16.   e.preventDefault();
  17.   var jqxhr = $.ajax({
  18.     url: url,
  19.     method: "GET",
  20.     dataType: "json",
  21.     data: $form.serializeObject()
  22.   }).success(function(){
  23.          // do something
  24. alert('Inscription effectu\351e avec succ\350s.\nNous vous tiendrons inform\351 de nos concerts.\nA bientot !');
  25.       }
  26.     );
  27. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top