WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Plugin ajax call to wp-ajax.php in admin page returning 0

[Resolved] Plugin ajax call to wp-ajax.php in admin page returning 0

  • viter-z-bayraku
    Member

    @viter-z-bayraku

    My code is:

    jQuery.ajax({
    url: "<?php echo admin_url('admin-ajax.php'); ?>",
    type: 'POST',
    data: {
    action: 'stravyfuncajax'
    },
    dataType: 'html',
    success: function(response) {						alert(response);
    }
    add_action('wp_ajax_stravyfuncajax', 'testfunc11');
    add_action('wp_ajax_nopriv_stravyfuncajax', 'testfunc11');
    
    function testfunc11() {
    echo "2";
    die();
    }

    Please help. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • yannou974
    Member

    @yannou974

    hi

    did u debug it ?
    i’ve the same problem here …

    thanks

    viter-z-bayraku
    Member

    @viter-z-bayraku

    I dont remember how i fixed it, but now this code are working.

    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);
    				}
    			});
    		});	
    
    	});

    and code:

    add_action('wp_ajax_stravyfuncajax22', 'testfunc11');
    add_action('wp_ajax_nopriv_stravyfuncajax22', 'testfunc11');
    
    function testfunc11() {
    echo "2";
    die();
    }
    yannou974
    Member

    @yannou974

    Hi Viter,

    Thanks veru much, i’ll try it

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Plugin ajax call to wp-ajax.php in admin page returning 0’ is closed to new replies.