Wordpress Post没有重新成功

时间:2015-10-31 12:58:30

标签: php wordpress

我正在努力获得一个wordpress帖子返回成功我尝试了各种技术,我觉得这很接近但仍未获得成功消息

        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');// i never get to here no idea why
        }
        else {
           // Do something else
        }
     }
  });
});
}); //Modal event Ends

在我的函数php中我有foloiwng

wp_localize_script( 'inkthemes', 'MyAjax', array( 'ajaxurl' => 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");

0 个答案:

没有答案