Ajax call always returns 0

Question

I have a problem with AJAX returning 0 always!

I have done everything by the book and can’t figure out what is wrong? Please help!!

Here is my Ajax call:

//Pass data through AJAX
var amountToConvert = price;

jQuery.ajax({
      type:"POST",
      url: "../../wp-admin/admin-ajax.php", // our PHP handler file
      action: "ajaxConversion",
      data: {
          amount: amountToConvert
      },
      success:function(data){
      alert(data);
      },
      error: function(errorThrown){
          alert(errorThrown);
      } 

  });
return false;

And the function in functions.php is:

function ajaxConversion(){

$amount = mysql_real_escape_string($_POST['amount']);

echo $amount;

die();
};

add_action('wp_ajax_nopriv_ajaxConversion', 'ajaxConversion');
add_action('wp_ajax_ajaxConversion', 'ajaxConversion');
0
Kuka 5 months 2020-12-24T09:10:20-05:00 0 Answers 4 views 0

Leave an answer

Browse
Browse