Skip to content

Instantly share code, notes, and snippets.

Created January 12, 2014 15:18
What would you like to do?
Added CSRF token to AJAX calls using Form Serialization
<!-- create form with open_form() -->
<form action="" method="post" accept-charset="utf-8" id="login-form" class="login">
<div style="display:none">
<input type="hidden" name="csrf_test_name" value="80bfb80b356d6d31f4ce4dad0c6cf69e">
<!-- Update AJAX code to post serialized data -->
<script type="text/javascript">
$.post( ajax_url, $('#login-form').serialize(), function( response ) {
// response
}, 'json' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment