Fixed #30299 -- Removed jQuery dependency from getCookie() in CSRF docs.

This commit is contained in:
Tim Graham 2019-03-28 19:51:54 -04:00
parent 4400d8296d
commit 8e675e2bd8
1 changed files with 1 additions and 2 deletions

View File

@ -84,13 +84,12 @@ Acquiring the token is straightforward:
.. code-block:: javascript .. code-block:: javascript
// using jQuery
function getCookie(name) { function getCookie(name) {
var cookieValue = null; var cookieValue = null;
if (document.cookie && document.cookie !== '') { if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';'); var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) { for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]); var cookie = cookies[i].trim();
// Does this cookie string begin with the name we want? // Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) { if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); cookieValue = decodeURIComponent(cookie.substring(name.length + 1));