2014-07-22 75 views
-5

我面臨一個問題,我已經被問到了一個網站的問題。本頁面的形式:WordPress主題中的ajax聯繫表格的問題

http://www.emerygrid.ru/en/service/product-samples/

似乎並沒有在所有的工作......窗體甚至不進行驗證,更不用說發送電子郵件!

它應該首先確認(有錯誤處理),然後發送電子郵件(集WP選項)

我沒有對細節很多信息,但如果有人願意指出我在正確的方向,我很樂意提供信息。 請記住,我不是很強大的JQuery,所以你必須使它對我來說真的很簡單....

謝謝你們!

+3

這不太合適。這很好,做你的工作。如果您在章節或理解代碼時遇到問題,請詢問,而且人們會樂於幫助。不要只希望有人會爲你解決它。 –

回答

0

沒有任何反應,當你點擊你的JS,因爲提交你調用這個

$(".comment_form, .contact_form").submit(function(event),你已經使用event.preventDefault();,因此表單不顯示默認的行爲。檢查控制檯,你有一個錯誤js。它說

TypeError:$(...)。塊不是函數。

您需要先解決這些錯誤。

這是處理您的表單的js。

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"); 
         } 
        } 
+0

你是對的@Adeel ...由於驗證輸入的函數,默認行爲確實被禁用。我遇到另一篇文章,建議我用「jQuery」替換「$」作爲擺脫「不是功能」錯誤的一種方式。它的工作...現在我可以繼續與其餘的表單錯誤(其中大部分,大多是錯別字等) –

+0

好的。如果它確實幫助將其標記爲已檢查。 – Adeel