Support » Plugins » Admin-ajax returns a 0

  • I am trying to write a simple ajax call that grabs the value of an input on blur and returns it. The ajax call is in a folder called ‘scripts’ in my themes directory and the function is in functions.php. My code is as follows:

    	var cardAmt = $(this).val();
    		type: 'POST',
    		url: '/../../../../wp-admin/admin-ajax.php',
    		data: {
    			action: 'populate_qualified_cards',
    			cardAmt: cardAmt,
    		success: function(data){
    		error: function(){

    and in functions.php i have:

    function populate_qualified_cards(){
        $amt = $_POST['cardAmt'];
        echo $amt;
    add_action( 'wp_ajax_nopriv_populate_qualified_cards', 'populate_qualified_cards' );
    add_action( 'wp_ajax_populate_qualified_cards', 'populate_qualified_cards' );

    Any ideas why I only get a zero in the console log? Help please!!!!!

  • The topic ‘Admin-ajax returns a 0’ is closed to new replies.