Support » Themes and Templates » jQuery Ajax call

  • Hello,

    I’m making my first custom Ajax call in a single.php theme file.
    here’s my js code:

    		                        jQuery("#mp3file").live("click", function(){
    	type: "POST",
    	url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
    	data: "action=update",
    	success: function(data){
            complete: function(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?


Viewing 2 replies - 1 through 2 (of 2 total)
  • data: {action: 'update'}
    doesn’t work either

    Forgot the mention the problem 😀

    The problem is that I don’t get any feedback, no error, just the POST request in Firebug that “turns” red?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘jQuery Ajax call’ is closed to new replies.