diff --git a/js/video_player.js b/js/video_player.js index 993b526a97..5394ae4552 100644 --- a/js/video_player.js +++ b/js/video_player.js @@ -1,11 +1,28 @@ // Things to abstract out to another file -function postJSON(url, data, callback, csrf) { - $.ajax({ - url: url, - dataType: 'json', - data: data, - success: callback +function getCookie(name) { + var cookieValue = null; + if (document.cookie && document.cookie != '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) == (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; +} + +function postJSON(url, data, callback) { + $.ajax({type:'POST', + url: url, + dataType: 'json', + data: data, + success: callback, + headers : {'X-CSRFToken':getCookie('csrftoken')} }); }