Success not being returned from ajax post

admin

Administrator
Staff member
AJAX Post is not returning success call in wordpress. I have the following code and I can get to the first dialog box in testing, but no mater what I do its not getting to the second. It's not finding the function in
Code:
functions.php
even though I have it declared.

Code:
    jQuery(document).ready(function(){
    jQuery("#send_btn").click(function(){

    var datastring = $("#redemmpointsForm").serialize();

      var points = $('#points').val();
      var comments = $('#comments').val();

          jQuery.ajax({
             type : "post",
             dataType : "json",
             url : myAjax.ajaxurl,
             data : {"action": "redeempoints", "points":points},
             success: function(response) {
                if(response.type == "success") {
                 alert('do i get here');
                }
                else {
                   // Do something else
                }
             }
          });
    });
     }); //Modal event Ends

functions.php file

Code:
wp_localize_script( 'inkthemes', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php')));

function functionRedeempoints() {

die();
return true;
}

add_action("wp_ajax_functionRedeempoints", "functionRedeempoints");
add_action("wp_ajax_nopriv_functionRedeempoints", "functionRedeempoints");

<strong>Ok so i treid the following</strong>

Code:
jQuery(document).ready(function(){
jQuery("#send_btn").click(function(){

var points = jQuery('#points').val();
var comments = jQuery('#comments').val();

         var allData = {
   action: 'functionRedeempoints',
   points: points,
   comments:comments
}
       var data = JSON.stringify(allData);   

           alert( data);

          jQuery.ajax({
             type : "post",
             dataType : 'json',
             url : myAjax.ajaxurl,
             data : data,
             success: function(response) {
            if(response.success) {
             alert('do i get here');
            }
            else {
               // Do something else
            }
         }
      });
});
 }); //Modal event Ends

And iN MY FUCNTIONS php Its like its not fidning the php function.

Code:
  wp_localize_script( 'inkthemes', 'MyAjax', array( 'ajaxurl' =&gt; admin_url( 'admin-ajax.php')));

function functionRedeempoints() {
wp_send_json_success(true);
}

add_action("wp_ajax_redeempoints", "functionRedeempoints");
add_action("wp_ajax_nopriv_redeempoints", "functionRedeempoints");