js: wrap CSRF javascript in jQuery(function(){})

Also remove the unnecessary `csrftoken` variable and use the `getCookie`
function directly.
Merge pull request #297 from blueyed/ajax-csrf-on-dom-ready

js: wrap CSRF javascript in jQuery(function(){})