[Solved] Issues with ajax contact form inside wordpress theme [closed]


Nothing Happens when you click submit because in your js you are calling this

$(".comment_form, .contact_form").submit(function(event) and you have used event.preventDefault(); , therefore the form does not show default behavior. Check the console there is an error in you js. It says

TypeError: $(…).block is not a function.

you need to fix these errors first.

This is the js which is handling your form.

 if($(".contact_form").length)
            $(".contact_form")[0].reset();
        if($(".comment_form").length)
            $(".comment_form")[0].reset();
        $(".comment_form, .contact_form").submit(function(event){
            event.preventDefault();
            var data = $(this).serializeArray();
            var id = $(this).attr("id");
            $("#"+id+" .block").block({
                message: false,
                overlayCSS: {
                    opacity:'0.3',
                    "backgroundColor": "#FFF"
                }
            });
            $.ajax({
                url: config.ajaxurl,
                data: data,
                type: "post",
                dataType: "json",
                success: function(json){
                    //$("#"+id+" [name="submit"], #"+id+" [name="name"], #"+id+" [name="contact_name"], #"+id+" [name="telephone"], #"+id+" [name="email"], #"+id+" [name="products"]").qtip('destroy');
                    if(typeof(json.isOk)!="undefined" && json.isOk)
                    {
                        if(typeof(json.submit_message)!="undefined" && json.submit_message!="")
                        {
                            $("#"+id+" [name="submit"]").qtip(
                            {
                                style: {
                                    classes: 'ui-tooltip-success'
                                },
                                content: { 
                                    text: json.submit_message 
                                },
                                position: { 
                                    my: "right center",
                                    at: "left center" 
                                }
                            }).qtip('show');
                            //close tooltip after 5 sec
                            /*setTimeout(function(){
                                $("#"+id+" [name="submit"]").qtip("api").hide();
                            }, 5000);*/
                            if(id=="comment_form" && typeof(json.html)!="undefined")
                            {
                                $(".comments").html(json.html);
                                $("#comment_form [name="comment_parent_id"]").val(0);
                                if(typeof(json.comment_id)!="undefined")
                                {
                                    var offset = $("#comment-" + json.comment_id).offset();
                                    $("html, body").animate({scrollTop: offset.top-10}, 400);
                                    if(typeof(json.change_url)!="undefined" && $.param.fragment()!=json.change_url.replace("#", ""))
                                        $("#comment_form [name="prevent_scroll"]").val(1);
                                }
                                if(typeof(json.change_url)!="undefined" && $.param.fragment()!=json.change_url.replace("#", ""))
                                    $.bbq.pushState(json.change_url);
                                    //window.location.href = json.change_url;
                            }
                            $("#"+id)[0].reset();
                            $("#cancel_comment").css("display", "none");
                            $(".contact_form [name="department"]").val("");
                            $(".contact_form .tabs_box_navigation_selected>span").text("Select department");
                        }
                    }

2

solved Issues with ajax contact form inside wordpress theme [closed]