简体   繁体   中英

Having trouble adding a contact form to wordpress site

I am trying to add a contact form to my wordpress site, the form I am using is identical to one I have used on this non wordpress site http://drains2go.com/contact.php the only thing I hae done differently has been update the action attribute to:

<form id="contact-form" action="<?php bloginfo('stylesheet_directory') ?>/processForm.php" method="post">

Problem is that my when I submit the form my javascript ajax call isnt made and the action attr link is followed instead of the default state being disabled.

Javascript

$.ajax({
        url : contactForm.attr('action') + '?ajax=true',
        type : contactForm.attr('method'),
        data : contactForm.serialize(),
        success : function() {

Is the problem that I have set the action as the full link?

http://localhost/jmccplantsales/wp-content/themes/child-theme/processForm.php

If you're using custom theme (other than the default or wordpress builtin themes like twentyelevan, twentyten etc).

  1. Change

     <form id="contact-form" action="<?php bloginfo('stylesheet_directory')?>/processForm.php" method="post"> 
  2. And try to use this one

     <form id="contact-form" action="<?php bloginfo('template_url')?>/processForm.php" method="post"> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM