I have a popup box name "Delete My account" where I am getting the password and delete account this password, below is the button where I click to open popup box:
<table align="center" width="100%">
<tr>
<td>
<div class="btn_delmyaccount" align="center">
<a id="DeleteMyAccount" class="buttonSearch">Delete My Account</a>
</div>
</td>
</tr>
</table>
by using this javascript, open popup box:
<script type="text/javascript">
var e2=document.getElementById("DeleteMyAccount");
e2.onclick = show_dialog3;
function show_dialog3() {
$( "#dialog2" ).dialog();
}
</script>
And below is he popup form:
<div id="dialog2" title="Delete My Account" hidden="true">
<%= form_tag({ controller: "settings", action: "delete_my_account"}, remote: "true" ) do |f| %>
<table style="text-align:center; vertical-align:top;">
<tr>
<td>
<div>
<%= label_tag(:password, "Password") %>
<%= password_field :tf_password, :placeholder => "Password" %>
</div>
</td>
</tr>
</table>
<table align="center" width="63%">
<tr>
<td style="text-align:right;">
<%= submit_tag 'Submit', :id => "_button1" %>
</td>
</tr>
</table>
<% end %>
</div
And below is javascript for submitting the form:
<script type="text/javascript">
$(document).ready(function() {
// '_button' is the Id of your submit button
$("#_button1").click(function() {
$(this).closest("form").submit();
$("#dialog2").dialog("close");
});
});
</script>
And problem is that when I click submit button on the popup box, I am getting an error below:
ActionController::InvalidAuthenticityToken
To resolve this issue I add authenticity_token: "true"
in form like below:
<%= form_tag({ controller: "settings", action: "delete_my_account" , authenticity_token: "true" }, remote: "true" ) do |f| %>
<% end %>
After that still I am getting another error below:
ActionController::InvalidAuthenticityToken
Kindly suggest me, what should I do to resolve this issue, waiting for your reply. Thanks.