I do not know why this response me -1 always? I am using this code in my plugin file. i want response on click p tag
<?php function myajax(){ ?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#testbutton").click(function(){
jQuery.ajax({
url: "<?php echo admin_url('admin-ajax.php'); ?>",
type: 'POST',
data: {
action: 'stravyfuncajax22'
},
dataType: 'html',
success: function(response) {
alert(response);
}
});
});
});
</script><?php
echo'
<p id="testbutton1">click</p>';
}
add_shortcode("my_ajax", "myajax");
add_action('wp_ajax_stravyfuncajax22', 'testfunc11');
add_action('wp_ajax_nopriv_stravyfuncajax22', 'testfunc11');
function testfunc11() {
echo "2";
die();
}
?>
EDIT : added php tag now....
<?php ?>tags. – soulseekah Mar 29 '12 at 20:24