Ajax returning the success value as -1

Below is the code i’m using. When ever i use to return some value , it’s returning as -1. Please tell me where i made the mistake or guide me what’s the pbm in the code!

Javascript:

Read More
$j = jQuery.noConflict();
$j.ajax({
url:"<?php echo admin_url( 'admin-ajax.php' ); ?>",
type:"POST",
data:"action=market_place_youtube_validator&id="+code,
success:function(data){$j("#loading").hide();$j("#mine").append(data);}
});

PHP (admin-ajax.php):

function market_place_youtube_validator()
{
echo "Yes Youtube is right";
}

Related posts

Leave a Reply

3 comments

  1. Do you have this in your functions.php?

    add_action('wp_ajax_nopriv_market_place_youtube_validator', 'youtube_validator');
    

    Where wp_ajax_nopriv_[your action parameter name]

    $j = jQuery.noConflict();
    $j.ajax({
    url:"<?php echo admin_url( 'admin-ajax.php' ); ?>",
    type:"POST",
    data:"action=market_place_youtube_validator&id="+code,
    success:function(data){$j("#loading").hide();$j("#mine").append(data);}
    });
    function youtube_validator()
    {
    echo "Yes Youtube is right";
    }