/**
 * @package     SP Soccer
 *
 * @copyright   Copyright (C) 2010 - 2016 JoomShaper. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

//Ajax Contact Form
jQuery(function($) {
    $('.sppb-ajax-poll-form').on('submit', function(event) {

        event.preventDefault();

        var $self   = $(this);
        var value   = $(this).serializeArray();
        var request = {
            'option' : 'com_sppagebuilder',
            'task'   : 'ajax',
            'addon'  : 'soccer_poll',
            'data'   : value
        };

        $.ajax({
            type   : 'POST',
            data   : request,
            beforeSend: function(){
                $self.find('.fa').addClass('fa-spinner fa-spin');
            },
            error: function(e) {
                console.log(e);
            },
            success: function (response) {
                $self.find('.fa-spin').removeClass('fa-spinner fa-spin');
                //$self.next('.sppb-ajax-poll-status').html($.parseJSON(response).data).fadeIn().delay(2000).fadeOut(500);;
            }
        });

        return false;
    });
});
