Utilities¶
-
getCookie(name)¶ Looks for a cookie, and if found, returns the values.
Note
Only the first item in the array is returned to eliminate the need for array deconstruction in the target.
Attention
The function catches the TypeError and returns
nullif thenameprovided for the cookie is not found. A notification is then provided in the console to inform the developer that the requested cookie does not exist.Arguments: - name (string) – The name of the cookie.
:returns: Value of the cookie with the key
nameornull.
- name (string) – The name of the cookie.
:returns: Value of the cookie with the key
-
preparePostData(data)¶ Creates a new instance of FormData to be used in AJAX calls.
Arguments: - data (Object) – Data to be embedded in the form in JSON format, where the key is the name/ID of the field
whose values are to be altered/created and corresponds to
dictkeys in Djangorequest.POST. - csrf (Boolean) – If
true, includes the CSRF token (under the namecsrfmiddlewaretoken) in the form. Default istrue.
Returns: A new instance FormData that incorporated the data embedded in
dataand the CSRF token in enabled.Return type: FormData
- data (Object) – Data to be embedded in the form in JSON format, where the key is the name/ID of the field
whose values are to be altered/created and corresponds to