Q:

Wordpress ajax request not working properly

I am new to wordpress, i make a ajax request on click button and it print the data, but ajax is not giving me any response. Please help me to find out the error.
Here is my code
add_action("wp_ajax_delivery_options", "delivery_options");
add_action("wp_ajax_nopriv_delivery_options", "delivery_options");

function delivery_options()
{
    echo json_encode(array('type' => 'success'));
    wp_die();
}

wp_enqueue_script("my-ajax-handle", get_stylesheet_directory_uri() . "/js/custom.js", array('jquery'));
wp_localize_script('my-ajax-handle', 'the_ajax_script', array('ajaxurl' => admin_url('admin-ajax.php')));

Ajax
(function($) {
  $(document).ready(function() {
    $('#delivery_option button').on('click', function(e) {
      e.preventDefault();
      var data = e.currentTarget.id;
      $.ajax({
        type: 'POST',
        dataType: 'json',
        url: the_ajax_script.ajaxurl,
        data: { delivery_option: data },
        success: function(response) {
          console.log(response);
        }
      });
    });
  });
})(jQuery);

Any solution appreciated!

A:

you have to pass "callback function name" in data: { action: 'delivery_options', delivery_option: data },
(function($) {
$(document).ready(function() {
  $('#delivery_option button').on('click', function(e) {
    e.preventDefault();
    var data = e.currentTarget.id;
    $.ajax({
      type: 'POST',
      dataType: 'json',
      url: the_ajax_script.ajaxurl,
      data: { action: 'delivery_options', delivery_option: data },
      success: function(response) {
        console.log(response);
      }
    });
  });
});})(jQuery);

