Proper way to send an Authenticity Token with AJAX to Rails
Actually, you are reading the action attribute of form and sending a post ajax request to it. to send form data you have to submit the form or you can serialize the form data and send it in ajax request like $(“.ajax-referral”).click(function(){ $.ajax({ type: “POST”, url: $(this).parent(“form”).attr(“action”) + “?&authenticity_token=” + AUTH_TOKEN, data:$(this).parent(“form”).serialize(), dataType: “script” }); … Read more