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:
$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";
}
You are using PHP (
echo "Yes Youtube is right";
) within javascript. To return a value you would need to doreturn "Yes Youtube is right";
Do you have this in your functions.php?
Where wp_ajax_nopriv_[your action parameter name]
I think you have to call die or exit after the output is being echo to the browser to prevent returning value -1