I've got a couple AJAX demands getting used inside a theme options page. Both labored all right before, however the very first works and also the second fails each time - the failure appears like this in Firebug: http://cl.ly/1w5u which is in Webkit: cl.ly/1wYn. I am not receiving ANY response of any sort. The truth is, the first works all right.

Here's the JS (jQuery) that submits:

 var pid = jQuery('#tump_header_img').val();
 var path = jQuery('#header_img_edit .container img').attr('src');
 var dimensions = jQuery('#tump_header_img_position').val();

 var security = jQuery('#_ajax_nonce_crop_apply_image').val();

 jQuery.post(ajaxurl, {pid: pid, action: 'crop_apply_header_image', path: path, dimensions: dimensions, security: security}, function(response) {

ajaxurl is correct, it is the identical URL utilized in the request that works. I have attempted draining out everything and merely looking to get an answer, with no success.

The great stuff in functions.php:

    add_action('wp_ajax_crop_apply_header_image', 'crop_apply_header_image');

    function crop_apply_header_image() {
     check_ajax_referer('crop_apply_header_image', 'security'); 

     $data = $_POST;
     unset($data['security'], $data['action']);

     $dimensions = explode(',',$data['dimensions']);

     $extension_pos = strrpos($data['path'], '/'); // find position of the last dot, so where the extension starts
     $newpath = substr($data['path'], 0, ($extension_pos +1)) . 'cropped-' . substr($data['path'], ($extension_pos + 1));

     update_option( 'tump_header_img_path', $newpath );

     die( wp_crop_image($data['pid'],$dimensions[0],$dimensions[1],$dimensions[2],$dimensions[3],940,200) );

Anyways - it reaches none of the so far as I will tell. I'm not sure wrong, any assistance is greatly appreciated!

If wp_crop_image gives a mistake, can you view it? Perhaps you have enabled debugging? Would you see something whenever you place a var_dump($data) there?

Try intercepting the control flow where it hits your server, at admin-ajax.php. Place a var_dump that only triggers whenever your code is known as:

if ($_REQUEST['action'] == 'crop_apply_header_image') {

If you notice this, the mistake happens somewhere within the WordPress code, but there is not an excessive amount of it between that time as well as your handler function. Your action should trigger in the finish from the switch statement, within the default part:

default :
    do_action( 'wp_ajax_' . $_POST['action'] );

Try printing something in the do_action function (but only when $_REQUEST['action'] == 'crop_apply_header_image'), and go lower after that.

For those who have XDebug or even the Zend Debugger setup (well worth the some time and troubles), you are able to step with the code without each one of these print claims. However for an easy debug such as this, it will work.