WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have problem. I don't know why but my paramters from form don't pass too aad_process_ajax().

My code from functions and jquery:

Function with my form:

function aad_render_admin() {

    <div class="wrap">
        <h2><?php _e('Admin Ajax Demo', 'aad'); ?></h2>
            <div class="wrap">
        <form id="aad-form" action="" method="POST">
<input type="text" name="name" />
<input type="text" name="header" />
<input type="text" name="body" />
<input type="text" name="urls" />
                <input type="submit" name="aad-submit" id="aad_submit" class="button-primary" value="<?php _e('Get Results', 'aad'); ?>"/>
                <img src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting" id="aad_loading" style="display:none;"/>
        <div id="aad_results"></div>

Jquery code:

jQuery(document).ready(function($) {
    $('#aad-form').submit(function() {
        $('#aad_submit').attr('disabled', true);

      data = {
          action: 'aad_get_results',
          aad_nonce: aad_vars.aad_nonce

         $.post(ajaxurl, data, function (response) {
            $('#aad_submit').attr('disabled', false);

        return false;

And this function don't get my parameters why?

function aad_process_ajax() {
    global $wpdb;

    echo $name = $_POST['name'];
    $header = $_POST['header'];
    $body = $_POST['body'];
    $urls = $_POST['urls'];
    echo 'xxxx';

            array(    'name' => $name,
                    'header' => $header,
                    'body' => $body,
                    'urls' => $urls,
            array(    '%s',


Tell my why parameters don't show in function aad_process_ajax().

Problem is in Jquery or Wordpress?

share|improve this question
up vote 0 down vote accepted

In your jQuery code

 data = {
      action: 'aad_get_results',
      aad_nonce: aad_vars.aad_nonce

you are passing only action and aad_nonce, you are not passing form data.

If you want pass variables, you ave to pass it with ajax, use something like:

  data = {
      action: 'aad_get_results',
      aad_nonce: aad_vars.aad_nonce,
      form_data: $('#aad-form').serialize()

After that, in your aad_process_ajax function use:

function aad_process_ajax() {

  parse_str($_POST['form_data'], $form_data);
  $name = isset($form_data['name']) ? : '';
  $header = isset($form_data['header']) ? : '';
  $body = isset($form_data['body']) ? : '';
  $urls = isset($form_data['urls']) ? : '';

  // the rest of your code here

share|improve this answer
i try it........ – user33913 Aug 20 '13 at 20:46
when i call echo $name = isset($form_data['name']) ? : ''; I got 1? Edit: Ok Thx work thanks:) – user33913 Aug 20 '13 at 21:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.