$(document).ready(function(){
    $("#mailingListRegistrationForm").on("submit",mailingListRegister);
});
function mailingListRegister(event){

    var datas = $("#mailingListRegistrationForm").serialize();
    var $result = $(".mailingListResult");
    $result.html("Registering...").show("fast");
    event.preventDefault();
    $.ajax({
            url: "actions/mailingListRegister.php",
            type: 'POST',
            dataType: 'html',
            enctype: 'multipart/form-data',
            data: datas,
            success: function(response, textStatus, XMLHttpRequest) {
                if (!response){
                    $result.html("There was an error!");
                    return false;
                }
                else {
                    $result.html(response);
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                $result.html("There was an error!");
                if (typeof console != 'undefined')
                    console.dir(XMLHttpRequest);
                return false;
            }
    });

}