Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8056815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:49:59+00:00 2026-06-05T08:49:59+00:00

I’m making a WordPress theme where every post will have a contact form. The

  • 0

I’m making a WordPress theme where every post will have a contact form. The contact form will collect information about the visitor and send a mail to the site administrator. It will also send an email to the visitor with a link to a downloadable PDF (this code is not done yet).

The problem I have is that the php function that handles the ajax form doesn’t respond. It only returns a -1 (No Properties). But I get a status code 200 OK.

I’m running the dev server on MAMP Pro OSX and DynDNS.

This is the PHP I have in functions.php

function ajax_contact() {

  if(!empty($_POST)) {
  $name = $_POST['name'];
  $company = $_POST['company'];
  $mail = $_POST['mail'];
  $admin_mail = get_bloginfo('admin_email');
  $error = "";
  if(!$name) {
      $error .= "Please tell us your name<br/>";
  }
  if(!$company) {
      $error .= "Please tell us your company<br/>";
  }
  if(!$mail) {
      $error .= "Please tell us your E-Mail address<br/>";
  }

  if(empty($error)) {
      $subject = "New download notification";
      $message = "You've received a new download notification. \n\n
          Name: ".$name."\n
          Company: ".$company."\n
          Mail: ".$mail."\n";

      // Send a mail to the admin with the contact info.    
      $send_mail = wp_mail($admin_mail, $subject, $message);

      // Send mail to visitor with the download link.

      if($send_mail) {
      echo "sent";
      die();
      }

  } else {
      echo "error: " . $error;
      die();
    }
  }
}

add_action('wp_ajax_nopriv_ajax_contact', 'ajax_contact');
add_action('wp_ajax_ajax_contact','ajax_contact');

This is the javascript code

    function sendForm(formId, postId, str)
{

    console.log("formId: " + formId);
    console.log("formId: " + postId);
    console.log("str: " + str);

    $.ajax({
        type: "POST",
        url: "../wp-admin/admin-ajax.php",
        action: "ajax_contact",
        data: str,
        success: function(data) {

            $("#" + formId).ajaxComplete(function(event, request, settings){

            if(data == 'sent') {
                $("#" + formId).find(".success").fadeIn("slow");
                }
                else {
                result = data;
                $("#" + formId).siblings(".success").html(result);
                }
            });

        }
    });


}

And this is the actual form (I have multiple forms on the same page)

<form name="form-<?php the_ID(); ?>" id="form-<?php the_ID(); ?>"/>
    Name <br/> 
    <input type="text" name="name" value=""/><br />
    Company / Organisation <br/> 
    <input type="text" name="company" value=""/><br />
    Email <br/> 
    <input type="text" name="mail" value=""/><br />

    <input type="hidden" name="postId" value="<?php the_ID(); ?>">

    <input type="submit" value="submit" class="requestbutton" id="requestButton-<?php the_ID(); ?>" rel="<?php the_ID(); ?>"/>
  </form>

EDIT: Changed the ajax action name, problem still persists

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:50:02+00:00Added an answer on June 5, 2026 at 8:50 am

    Your AJAX action: should be contact_form not ajax_contact

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.