AJAX form post returns 0

I am working on a simple plugin that shows an HTML form where the user can input a keyword which is used to query an external API. I currently have the form and the related jQuery set up, but when passed to the plugin’s PHP file, I get a response of simply 0. At this point I’m only just trying to get any response but 0 (see the echo "Whyyyy" part). I’ve been scouring the internet and feel like I have tried everything that’s been suggested, leading me to think I’m making a mistake somewhere.

Any help would be greatly appreciated. 🙏

This is the plugin’s PHP:

defined('ABSPATH') or die('Ah ah ah. You didn\'t say the magic word.');  class News_search {      // Load scripts upon class initiation     public function __construct() {         add_action('wp_enqueue_scripts', array($  this, 'enqueue_scripts'));         add_action('wp_ajax_get_news_callback', 'get_news_callback');         add_action('wp_ajax_nopriv_get_news_callback', 'get_news_callback');         add_shortcode('wp_news_search', array($  this, 'wp_news_search_form'));     }      function enqueue_scripts() {         // Enqueue CSS         wp_enqueue_style('wp-news-search', plugins_url('/css/wp-news-search.css', __FILE__));         // Enqueue and localize JS         wp_enqueue_script('ajax-script', plugins_url('/js/wp-news-search_query.js', __FILE__), array('jquery'), null, true);         wp_localize_script('ajax-script', 'ajax_object',             array('ajax_url' => admin_url('admin-ajax.php'),                 'security' => wp_create_nonce('my-string-shh'),             ));     }      // Handle AJAX request     function get_news_callback() {         check_ajax_referer('my-special-string', 'security');         $  keyword = isset($  _POST['news-keyword']) ? $  _POST['news-keyword'] : null;         echo "Whyyyy";         die();      }      public function wp_news_search_form() {         $  content .= '<form id="wp-news-search__form">                         <label>                             <input type="text" name="news-keyword" placeholder="' . __('Enter keywords') . '" id="news-keyword" required>                         </label>                         <button id="wp-news-search__submit">' .                          __('Search for news', 'wp-news-search') .                        '</button>                     </form>';         return $  content;     }  }  new News_search(); 

And this is the JS file:

(function ($  ) {      $  (document).ready(function () {         $  ('#wp-news-search__form').submit(function (event) {             event.preventDefault();              // const keyword = $  ('#query-input').val();             const values = $  (this).serialize();               if (values) {                 // send stuff to php                 console.log(values);                 const data = {                     action: 'get_news_callback',                     status: 'enabled',                     security: ajax_object.security,                     form_data: values                 }                  $  .post(ajax_object.ajax_url, data, function(response) {                     if (response) {                         console.log(`Response is: $  {response}`);                     }                 })                     .fail(() => { console.error('error'); })                     .always(() => { console.log('form submitted') });             }          });       });  })(jQuery); 

Capture User Email Address When Filling Out Form

We have a snippet of code that was provided by an optimization platform company we use that provides a real-time personalization to our website.

The user will fill out a form (Gravity Forms) and then be sent to one of our WordPress Thank You pages.

This code will be added to the Thank You page, but needs to be updated to capture the user’s email address once the Gravity Form has been completed:

<img src="//dasd65f4ds3e25u.cloudfront.net/pc/p5w6g1jy/?e=[customer's email address]" id="__tms_pc" height="1" width="1" /> 

Would you be able to help me replace the "customer’s email address" text with the appropriate code that will be able to capture each user’s email address when they fill out the form?

Is there a PHP string of code that could be used to replace the "customer’s email address" text? I have not been able to find a concrete answer while doing some research for this.

Ajax contact form widget plugin data not insert in database

I have been working at this for weeks without success. I’ve figured out problem after problem with the code, but none of the corrections seem to fix my core problem. The form doesn’t insert anything into the database and I don’t know why. all my data’s passed in the ajax call but it doesn’t insert in the data in the database.

I’m new to ajax and to WordPress plugins so I might be missing something obvious. Please help me know where I am going wrong. Thanks in advance.

My widget form plugin code

public function widget( $  args, $  instance ) {       if ( ! isset( $  args['widget_id'] ) ) {          $  args['widget_id'] = $  this->id;                  }          $  title = ( ! empty( $  instance['title'] ) ) ? $  instance['title'] : __( 'Contact' );          $  title = apply_filters( 'widget_title', $  title, $  instance, $  this->id_base );                            ?>     <?php         if ( $  title ) {            echo '<h2 class="widget-title">'.$  args['before_title'] . $  title . $  args['after_title'].'</h2>';                    }        ?>      <form  class="form-group" method="POST" id="form" action="">         <label>Name</label><br>         <input class="form-control" type="text" id="name" name="name" ><br>         <label>Mobile</label><br>         <input type="text" class="form-control" id="mobileno" name="mobileno" required><br>         <label>Email</label><br>         <input class="form-control"  type="email" id="email" name="email" ><br>         <label>Message</label><br>         <textarea class="form-control" id="message" name="message"  maxlength="10" onKeyPress="lengthcheck()"></textarea><br><br>         <button  class="btn btn-warning" type="submit" id="submit">Send Message</button>     </form> <?php }    

This is my enqueue methods:

add_action( 'wp_enqueue_scripts', 'vs_con_enqueue_scripts' );  function vs_con_enqueue_scripts(){  wp_register_script(     'ajaxHandle',     plugins_url('valid.js', __FILE__),     array('jquery'),     false,     true   );  wp_enqueue_script( 'ajaxHandle');  wp_localize_script(     'ajaxHandle',     'ajax_object',     array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) )   );  wp_enqueue_style( 'bootstrap-style','https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );  }   add_action( "wp_ajax_contact", "vs_contact_form" ); add_action( "wp_ajax_nopriv_contact", "vs_contact_form" );   function vs_contact_form(){     global $  wpdb;         $  name = $  _POST["name"];        $  email = $  _POST["email"];        $  mobileno = $  _POST["mobileno"];        $  messsage = $  _POST["messsage"];                $  tablename = $  wpdb->prefix.'contactdetails';        $  insert_row = $  wpdb->insert(           $  tablename,             array(                 'name' => $  name,                 'email' => $  email,                 'mobileno' => $  mobileno,                'messsage' => $  messsage             )          );            // if row inserted in table         if($  insert_row){            echo json_encode(array('res'=>true, 'message'=>__('Message Sent Successfully')));        }else{           echo json_encode(array('res'=>false, 'message'=>__('Something went wrong. Please try again later.')));        }        wp_die(); }  

Here this is my form submit jquery ajax call function


jQuery(document).ready(function($  ){     $  ('form#form').on('submit', function(e){        e.preventDefault();        var name =jQuery('#name').val();        var email = jQuery('#email').val();        var mobileno = jQuery('#mobileno').val();        var message = jQuery('#message').val();        debugger;        var text;        if(name.length < 5){          text = "Please Enter valid Name";         alert(text);          return false;        }        if(isNaN(mobileno) || mobileno.length != 10){          text = "Please Enter valid mobileno Number";          alert(text);          return false;        }        if(email.indexOf("@") == -1 || email.length < 6){          text = "Please Enter valid Email";          alert(text);          return false;        }                $  .ajax({           url: ajax_object.ajaxurl,           type:"POST",           dataType:'json',           data: {              action:'contact',              name: name,              email: email,              mobileno: mobileno,              message: message         },   success: function(data){             if (data.res == true){                 alert(data.message);    // success message             }          }, error: function(data){             if (data.res == false){                 alert(data.message);    // success message             }            }        });     $  ('#form')[0].reset();       });     });  

please help me to find out where I am wrong?

Is concealed difficulty an integral part of the cliffhanger scene form?

The “Cliffhangers” section in Masters of Umdaar says that the difficulties for rolls should be concealed until rolled against:

Of course, GMs, don’t reveal a difficulty for a specific approach until a player attempts it—let them stumble around to see which methods are more effective. (MoU 28, Cliffhangers: Running the Cliffhanger)

That stands out because it’s contrary to standard practices in Fate. On the one hand, that makes it feel like an optional playstyle preference note; on the other hand, it can be read as a deliberate and noteworthy departure from Fate norms to introduce a different sort of experience to the game.

Are concealed difficulties a crucial part of the cliffhanger concept or is this just a playstyle preference of the author? What difference does concealing difficulties make to the table experience when using cliffhangers?