AJAX returning 0
-
I am trying to do a basic ajax function but all I can get back is a 0. Code is as follows:
In my main script.js file I have:
function populateCardAmount(){ var cardAmt = $("#trading_card_amount").val(); $.ajax({ type: 'POST', url: '/wp-admin/admin-ajax.php', data: { action: 'populate_qualified_cards', cardAmt: cardAmt, }, success: function(data){ console.log(data); }, error: function(){ alert('error'); } }); }And in functions.php I have:
function populate_qualified_cards(){ $amt = $_POST['cardAmt']; print_r($amt); die(); } add_action( 'wp_ajax_nopriv_populate_qualified_cards', 'populate_qualified_cards' ); add_action( 'wp_ajax_populate_qualified_cards', 'populate_qualified_cards' );Help Please!!! Thank you!!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘AJAX returning 0’ is closed to new replies.