$(function() {
    $('#contact-form').submit(function(event){
        event.preventDefault();

        var parameters = {
            email: $( "input[name='email']" ).val(),
            name: $( "input[name='name']" ).val(),
            message: $( "textarea[name='message']" ).val(),
            action: "contact"
        };

        $.ajax({
            url: 'ajax',
            type: 'post',
            dataType: 'json',
            success: function (data) {
                if(data.success == true){
                    swal("Thank you for contacting us");
                }else{
                    swal({
                        title: "Something went Wrong",
                        text: "Please try contacting us later",
                        buttons: true,
                        type: 'warning'
                    })
                }
            },
            data: parameters
        });
    })
});
