Can you anyone help me to get the front_end ajax returns response value as 1.i have updated the below code is now returning response value as 0

if (isset($_POST['frontliveeditor_settings']) && isset($_POST['action']) && $_POST['action'] == "fnrlvedt_updateoption"){
    if (wp_verify_nonce($_POST['frontendlvedt'],'frnendlv_updateoptions')){ 
        update_option('frontliveeditor_settings', $_POST['frontliveeditor_settings']);

if(! function_exists( 'fend_clear_options' )):  
    function fend_clear_options(&$fend_value) {
       $fend_value = htmlspecialchars(stripslashes( $fend_value ));

if(! function_exists( 'fend_save_settings' )):  
   function fend_save_settings ( $fend_data , $fend_rfresh = 0 ) {
       global $fend_arrayoptions;
       $fend_arrayoptions = array( 'frontliveeditor_settings' );
       foreach( $fend_arrayoptions as $fend_option ){
           if( isset( $fend_data[$fend_option] )){
               array_walk_recursive( $fend_data[$fend_option] , 'fend_clear_options');
               update_option( $fend_option ,  $fend_data[$fend_option] );

       if( $fend_rfresh == 2 ) {    wp_die('2');}
       elseif( $fend_rfresh == 1 ){ wp_die('1');}


# Save Options

add_action('wp_ajax_fnrlvedt_updateoption', 'fnrlvedt_updateoption');
add_action('wp_ajax_nopriv_fnrlvedt_updateoption', 'fnrlvedt_updateoption');

if(! function_exists( 'fnrlvedt_updateoption' )):   
function fnrlvedt_updateoption() {

    check_ajax_referer('fend-theme-data', 'security');
    $fend_data = $_POST;

    $fend_rfresh = 1;

    fend_save_settings ($fend_data , $fend_rfresh );

<form id="frontlvedtr_saveoptions" class="frontlvedtr_hiddenitems" name="frontlvedtr_saveoptions" action="" method="post">  
<div class="frontlvedtr_hdltad1">   
enter your name : <input class="lt1hd1adcontnum" type="text" size="9" id="lveditlefthdad1" name="frontliveeditor_settings[lveditlefthdad1]" value="<?php echo intval(get_lveditoption('lveditlefthdad1')); ?>" />

<input type="hidden" name="action" value="fnrlvedt_updateoption"/>
<input type="hidden" name="security" value="<?php echo wp_nonce_field('fend-theme-data'); ?>" />
<input type="submit" name="frnendlv_updateoptions" value="Save" class="lvedtsubmtbtn"/>


jQuery('form#frontlvedtr_saveoptions').submit(function() {

          var data = jQuery(this).serialize();

          jQuery.post(stchk.fedajaxurl, data, function(response) {
          if(response == 1) {

          t = setTimeout('fademessage()', 3000);

          else if( response == 2 ){


          else {
              return false;

          return false;

Thanks in advance.

1 Answer 1


You're sending a bad action for your AJAX request, the action should match with your string next to wp_ajax_:

add_action('wp_ajax_fend_theme_data_save', 'fend_theme_data_save');, so your action HTML field should be like this:

<input type="hidden" name="action" value="fend_theme_data_save" />

See the difference? Your action value should always be next to wp_ajax_ or wp_ajax_nopriv, whatever you're using. I recommend you to read AJAX in Plugins.

Also, if you're using check_ajax_referer('fend-theme-data', 'security'); function, you should send the security parameter within your jQuery data with its respective value, read more about this function; in this case will be something like this:


your-nonce-string means that you need to create a nonce named fend-theme-data (the string that you're comparing with check_ajax_referer() function) and send it using wp_localize_script() function, read more about this function, and this one to create the nonce.

And, do not use die() PHP function, use wp_die() or wp_send_json_success or wp_send_json_error WordPress default functions.

I hope my answer helps you. :)

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Howdy_McGee
    Sep 12, 2017 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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