I have a couple AJAX requests being used in a theme options page. Both worked just fine before, but now the first works and the second fails every time - the failure looks like this in Firebug: http://cl.ly/1w5u and this is in Webkit: cl.ly/1wYn. I'm not getting ANY response of any kind. The thing is, the first one works just fine.
Here's the JS (jQuery) that submits:
jQuery('.cropimage').click(function(){
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) {
console.log(response);
});
});
ajaxurl is correct, it's the exact same URL used in the request that does work. I've tried stripping out everything and just trying to get a response, to no avail.
The good 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 gets to none of this as far as I can tell. I don't know what's wrong, any help is greatly appreciated!