Skip to content

Instantly share code, notes, and snippets.

View hanleyhansen's full-sized avatar
🏠
Working from home

Hanley Hansen hanleyhansen

🏠
Working from home
View GitHub Profile
@rca
rca / ajax_setup.js
Created January 29, 2012 00:27
Setup Django CSRF token in JQuery AJAX requests
/**
* setup JQuery's AJAX methods to setup CSRF token in the request before sending it off.
* http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
*/
function getCookie(name)
{
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');