Hello,
I'm making my first custom Ajax call in a single.php theme file.
here's my js code:
jQuery(document).ready(function(){
jQuery("#mp3file").live("click", function(){
jQuery.ajax({
type: "POST",
url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
data: "action=update",
success: function(data){
},
complete: function(data){
jQuery("#current_available_dl").html(data);
}
});
});
});
This is my code in the function.php file:
function update_available_downloads(){
global $post;
$custom = get_post_custom($post->ID);
$current = get_available_downloads($post->ID);
$new_value = $current - 1;
update_post_meta($post->ID, "current_amount_of_downloads", $new_value);
return $new_value;
}
add_action('wp_ajax_update', 'update_available_download');
add_action('wp_ajax_nopriv_update', 'update_available_download');
Don't see what I'm doing wrong here?
If anyone can help me out here?
Thanks!