Ajax Help
-
I’ve posted on here numerous times about ajax problems but no luck so far. Hopefully someone can help me. I have the following code in a js file:
//ajax user trade card value to see what they qualify for $(document).ready(function(){ $("#trade_submit").live('click',function(){ var cardAmt = '40'; $.ajax({ type: 'POST', url: '/wp-admin/admin-ajax.php', data: { action: 'populate_qualified_cards', cardAmt: cardAmt, }, success: function(data){ console.log(data); }, error: function(error){ alert(error); } }); }); });
And have the following in functions.php:
function populate_qualified_cards(){ $card_amt = $_POST['cardAmt']; echo $card_amt; die(); } add_action('wp_ajax_populate_qualified_cards', 'populate_qualified_cards'); add_action('wp_ajax_nopriv_populate_qualified_cards', 'populate_qualified_cards');
However, in the console where I append the data it is outputting a 0. I’ve tried hard-coding amounts in the php function and it still logs a 0.
WordPress Gods help!!!!!
[No bumping, thank you.]
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Ajax Help’ is closed to new replies.